Skip to content

Commit

Permalink
FIX: firmware version
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ Keller committed Feb 14, 2018
1 parent c7b49f4 commit 1f9986e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/python/handoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def main(argv):
print "sample is not a dict", message
raise ValueError
# Get keys of sample
data = np.zeros(9)
data = np.zeros(nb_chan + 1)

data[:-1] = message.get('channelData')
data[-1] = message.get('timeStamp')
Expand Down
2 changes: 1 addition & 1 deletion examples/python/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ourBoard.autoFindOpenBCIBoard().then(portName => {
// Call to connect
ourBoard.connect(portName)
.then(() => {
ourBoard.on('ready', () => {
ourBoard.once('ready', () => {
// Find out if you can even time sync, you must be using v2 and this is only accurate after a `.softReset()` call which is called internally on `.connect()`. We parse the `.softReset()` response for the presence of firmware version 2 properties.
timeSyncPossible = ourBoard.usingAtLeastVersionTwoFirmware();
console.log(`timeSyncPossible: ${timeSyncPossible}`);
Expand Down
16 changes: 5 additions & 11 deletions openBCICyton.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ Cyton.prototype.disconnect = function () {
*/
Cyton.prototype.isConnected = function () {
if (!this.serial) return false;
return this.serial.isOpen();
return this.serial.isOpen;
};

/**
Expand Down Expand Up @@ -636,7 +636,7 @@ Cyton.prototype.usingVersionTwoFirmware = function () {
if (this.options.simulate) {
return this.options.simulatorFirmwareVersion === k.OBCIFirmwareV2;
} else {
return this.info.firmware === k.OBCIFirmwareV2;
return this.info.firmware.major === 2;
}
};

Expand Down Expand Up @@ -664,7 +664,7 @@ Cyton.prototype.usingVersionThreeFirmware = function () {
if (this.options.simulate) {
return this.options.simulatorFirmwareVersion === k.OBCIFirmwareV3;
} else {
return this.info.firmware === k.OBCIFirmwareV3;
return this.info.firmware.major === 3;
}
};

Expand Down Expand Up @@ -1953,16 +1953,10 @@ Cyton.prototype._processParseBufferForReset = function (dataBuffer) {
this.overrideInfoForBoardType(k.OBCIBoardCyton);
}

const firmware = obciUtils.getFirmware(dataBuffer);
if (firmware) {
if (firmware.major === 2) {
this.info.firmware = k.OBCIFirmwareV2;
} else {
this.info.firmware = k.OBCIFirmwareV3;
}
this.info.firmware = obciUtils.getFirmware(dataBuffer);
if (this.info.firmware) {
this.writeOutDelay = k.OBCIWriteIntervalDelayMSShort;
} else {
this.info.firmware = k.OBCIFirmwareV1;
this.writeOutDelay = k.OBCIWriteIntervalDelayMSLong;
}
};
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openbci-cyton",
"version": "1.0.7",
"version": "1.0.8",
"description": "The official Node.js SDK for the OpenBCI Cyton with Dongle.",
"main": "openBCICyton.js",
"scripts": {
Expand All @@ -22,7 +22,7 @@
"openbci-utilities": "^0.2.7",
"performance-now": "^2.1.0",
"safe-buffer": "^5.1.1",
"serialport": "4.0.7",
"serialport": "^6.0.5",
"sntp": "^2.0.2"
},
"directories": {
Expand Down

0 comments on commit 1f9986e

Please sign in to comment.