Skip to content

Commit

Permalink
Merge pull request #71 from aj-ptw/dev-3.0.0
Browse files Browse the repository at this point in the history
FIX: Board wrote to Serial0 even if command came from wifi
  • Loading branch information
AJ Keller authored Aug 24, 2017
2 parents 3b19f76 + 9cd6c05 commit 8936b47
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
18 changes: 13 additions & 5 deletions OpenBCI_32bit_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,13 @@ boolean OpenBCI_32bit_Library::processChar(char character) {
return true;
}

boolean OpenBCI_32bit_Library::processCharWifi(char character) {
commandFromSPI = true;
boolean retVal = processChar(character);
commandFromSPI = false;
return retVal;
}

/**
* Used to turn on or off the accel, will change the current packet type!
* @param yes {boolean} - True if you want to use it
Expand Down Expand Up @@ -564,7 +571,7 @@ boolean OpenBCI_32bit_Library::boardBeginDebug(int baudRate) {
iSerial1.baudRate = baudRate;
// setSerialInfo(iSerial1, true, true, OPENBCI_BAUD_RATE);
// Serial0.print("begin S1 tx "); Serial0.println(iSerial1.tx ? "on" : "off");
Serial1.print("begin S1 tx "); Serial1.println(iSerial1.tx ? "on" : "off");
// Serial1.print("begin S1 tx "); Serial1.println(iSerial1.tx ? "on" : "off");

curBoardMode = BOARD_MODE_DEBUG;

Expand Down Expand Up @@ -594,7 +601,7 @@ void OpenBCI_32bit_Library::boardReset(void) {
printAll("On Daisy ADS1299 Device ID: 0x"); printlnHex(ADS_getDeviceID(ON_DAISY));
}
printAll("LIS3DH Device ID: 0x"); printlnHex(LIS3DH_getDeviceID());
printlnAll("Firmware: v3.0.0");
printlnAll("Firmware: v3.0.0-rc6");
sendEOT();
delay(5);
wifi.reset();
Expand Down Expand Up @@ -993,6 +1000,7 @@ void __USER_ISR ADS_DRDY_Service() {
void OpenBCI_32bit_Library::initializeVariables(void) {
// Bools
channelDataAvailable = false;
commandFromSPI = false;
daisyPresent = false;
isProcessingIncomingSettingsChannel = false;
isProcessingIncomingSettingsLeadOff = false;
Expand Down Expand Up @@ -2613,7 +2621,7 @@ void OpenBCI_32bit_Library::stopADS()
}

void OpenBCI_32bit_Library::printSerial(int i) {
if (iSerial0.tx) {
if (iSerial0.tx && !commandFromSPI) {
Serial0.print(i);
}
if (iSerial1.tx) {
Expand All @@ -2622,7 +2630,7 @@ void OpenBCI_32bit_Library::printSerial(int i) {
}

void OpenBCI_32bit_Library::printSerial(char c) {
if (iSerial0.tx) {
if (iSerial0.tx && !commandFromSPI) {
Serial0.print(c);
}
if (iSerial1.tx) {
Expand All @@ -2631,7 +2639,7 @@ void OpenBCI_32bit_Library::printSerial(char c) {
}

void OpenBCI_32bit_Library::printSerial(int c, int arg) {
if (iSerial0.tx) {
if (iSerial0.tx && !commandFromSPI) {
Serial0.print(c, arg);
}
if (iSerial1.tx) {
Expand Down
2 changes: 2 additions & 0 deletions OpenBCI_32bit_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ class OpenBCI_32bit_Library {
void printSerial(int, int);
void printSerial(const char *);
boolean processChar(char);
boolean processCharWifi(char);
void processIncomingBoardMode(char);
void processIncomingSampleRate(char);
void processIncomingChannelSettings(char);
Expand Down Expand Up @@ -289,6 +290,7 @@ class OpenBCI_32bit_Library {
byte xfer(byte); // SPI Transfer function

// Variables
boolean commandFromSPI;
boolean firstDataPacket;
boolean isProcessingIncomingSettingsChannel;
boolean isProcessingIncomingSettingsLeadOff;
Expand Down
7 changes: 7 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
* Removed public `waitForNewChannelData()`
* Removed public `timeSynced` and private `sendTimeSyncUpPacket`
* Setting internal test signal now, when not streaming, returns a success message, with EOT `$$$`
* Sending multi char messages now times out after a second of not completing the multichar message.

## Release Candidate 6

### Bug Fixes

* Even when command came from wifi, library printed to `Serial0`, which resulted in overflow of radio buffer which led to a reset.

## Release Candidate 5

Expand Down
2 changes: 1 addition & 1 deletion examples/BoardWithWifi/BoardWithWifi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void loop() {
sdProcessChar(newChar);

// Send to the board library
board.processChar(newChar);
board.processCharWifi(newChar);
}

if (!wifi.sentGains) {
Expand Down
3 changes: 1 addition & 2 deletions examples/DefaultBoard/DefaultBoard.ino
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ void loop() {
sdProcessChar(newChar);

// Send to the board library
board.processChar(newChar);
board.processCharWifi(newChar);
}

if (!wifi.sentGains) {
if(wifi.present && wifi.tx) {
// Serial0.println("Synced with Wifi$$$");
wifi.sendGains(board.numChannels, board.getGains());
}
}
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=OpenBCI_32bit_Library
version=3.0.0-rc5
version=3.0.0-rc6
author=Joel Murphy <[email protected]>, Conor Russomanno <[email protected]>, Leif Percifield <[email protected]>, AJ Keller <[email protected]>
maintainer=Joel Murphy <[email protected]>, AJ Keller <[email protected]>
sentence=The library for controlling OpenBCI Cyton (32bit) boards. The Cyton is the main one.
Expand Down

0 comments on commit 8936b47

Please sign in to comment.