Permalink
Browse files

Add tests for new daisy code and Enh separated radio tests from main …

…board test
  • Loading branch information...
1 parent 0dd0ece commit c2958f408e10c25702012655bdc5a35b929f5173 @aj-ptw aj-ptw committed Jan 3, 2017
Showing with 1,174 additions and 917 deletions.
  1. +8 −3 changelog.md
  2. +37 −4 openBCIBoard.js
  3. +2 −0 openBCIConstants.js
  4. +4 −1 test/OpenBCIConstants-test.js
  5. +954 −0 test/openBCIBoard-radio-test.js
  6. +169 −909 test/openBCIBoard-test.js
View
@@ -2,13 +2,18 @@
### New Features
* New simulator option `simulatorDaisyModuleCanBeAttached` - Boolean, deafults to true, allows the simulation of the a hot swapped daisy board or simulates a misinformed module.
+* New `EventEmitter` - `hardSet` - for when the module detects the board is not configured as the options for the module intended and tries to save itself. i.e. when the `daisy` option is `true` and a soft reset message is parsed and the module determines that a daisy was not detected, the module will emit `hardSet` then send an attach daisy command to recover. Either `error` will be emitted if unable to attach or `ready` will be emitted if success.
+
+### Breaking changes
+* `.setInfoForBoardType()` changed to `.overrideInfoForBoardType()` to elevate it's dangerous nature.
+* `.setMaxChannels()` changed to `.hardSetBoardType()` and input changed from numerical to string: 8 and 16 to `default` and `daisy` respectively.
### Bug Fixes
* Fixes #131 - 16 chan not working by sending a channel command and parsing the return.
* Fixed bug where end of transmission characters would not be ejected from buffer.
-
-### Breaking changes
-* `.overrideInfoForBoardType()` changed to `.overrideInfoForBoardType()` to elevate it's dangerous nature.
+
+### Enhancements
+* Separated radio tests from main board test file.
# 1.4.4
View
@@ -20,6 +20,7 @@ function OpenBCIFactory () {
var _options = {
boardType: [k.OBCIBoardDefault, k.OBCIBoardDaisy, k.OBCIBoardGanglion],
baudRate: 115200,
+ hardSet: false,
simulate: false,
simulatorBoardFailure: false,
simulatorDaisyModuleAttached: false,
@@ -54,6 +55,10 @@ function OpenBCIFactory () {
* `ganglion` - 4 Channel board
* (NOTE: THIS IS IN-OP TIL RELEASE OF GANGLION BOARD 07/2016)
*
+ * - `hardSet` {Boolean} - Recommended if using `daisy` board! For some reason, the `daisy` is sometimes
+ * not picked up by the module so you can set `hardSet` to true which will ensure the daisy
+ * is picked up. (Default `false`)
+ *
* - `simulate` {Boolean} - Full functionality, just mock data. Must attach Daisy module by setting
* `simulatorDaisyModuleAttached` to `true` in order to get 16 channels. (Default `false`)
*
@@ -1056,12 +1061,18 @@ function OpenBCIFactory () {
this.info.boardType = k.OBCIBoardDaisy;
this.info.numberOfChannels = k.OBCINumberOfChannelsDaisy;
this.info.sampleRate = k.OBCISampleRate125;
+ this.channelSettingsArray = k.channelSettingsArrayInit(k.OBCINumberOfChannelsDaisy);
+ this.goertzelObject = openBCISample.goertzelNewObject(k.OBCINumberOfChannelsDaisy);
+ this.impedanceArray = openBCISample.impedanceArray(k.OBCINumberOfChannelsDaisy);
break;
case k.OBCIBoardDefault:
default:
this.info.boardType = k.OBCIBoardDefault;
this.info.numberOfChannels = k.OBCINumberOfChannelsDefault;
this.info.sampleRate = k.OBCISampleRate250;
+ this.channelSettingsArray = k.channelSettingsArrayInit(k.OBCINumberOfChannelsDefault);
+ this.goertzelObject = openBCISample.goertzelNewObject(k.OBCINumberOfChannelsDefault);
+ this.impedanceArray = openBCISample.impedanceArray(k.OBCINumberOfChannelsDefault);
break;
}
};
@@ -1807,7 +1818,7 @@ function OpenBCIFactory () {
case k.OBCIParsingEOT:
if (openBCISample.doesBufferHaveEOT(data)) {
this.curParsingMode = k.OBCIParsingNormal;
- this.emit('eot', data);
+ this.emit(k.OBCIEmitterEot, data);
this.buffer = openBCISample.stripToEOTBuffer(data);
} else {
this.buffer = data;
@@ -1817,9 +1828,31 @@ function OpenBCIFactory () {
// Does the buffer have an EOT in it?
if (openBCISample.doesBufferHaveEOT(data)) {
this._processParseBufferForReset(data);
- this.curParsingMode = k.OBCIParsingNormal;
- this.emit('ready');
- this.buffer = openBCISample.stripToEOTBuffer(data);
+ if (this.options.hardSet) {
+ if (this.getBoardType() !== this.options.boardType) {
+ this.emit(k.OBCIEmitterHardSet);
+ this.hardSetBoardType(this.options.boardType)
+ .then(() => {
+ this.emit(k.OBCIEmitterReady)
+ })
+ .catch((err) => {
+ this.emit(k.OBCIEmitterError, err);
+ });
+
+ } else {
+ this.curParsingMode = k.OBCIParsingNormal;
+ this.emit(k.OBCIEmitterReady);
+ this.buffer = openBCISample.stripToEOTBuffer(data);
+ }
+
+ } else {
+ if (this.getBoardType() !== this.options.boardType && this.options.verbose) {
+ console.log(`Module detected ${this.getBoardType()} board type but you specified ${this.options.boardType}, use 'hardSet' to force the module to correct itself`);
+ }
+ this.curParsingMode = k.OBCIParsingNormal;
+ this.emit(k.OBCIEmitterReady);
+ this.buffer = openBCISample.stripToEOTBuffer(data);
+ }
} else {
this.buffer = data;
}
View
@@ -342,6 +342,7 @@ const obciEmitterClose = 'close';
const obciEmitterDroppedPacket = 'droppedPacket';
const obciEmitterEot = 'eot';
const obciEmitterError = 'error';
+const obciEmitterHardSet = 'hardSet';
const obciEmitterImpedanceArray = 'impedanceArray';
const obciEmitterQuery = 'query';
const obciEmitterRawDataPacket = 'rawDataPacket';
@@ -907,6 +908,7 @@ module.exports = {
OBCIEmitterDroppedPacket: obciEmitterDroppedPacket,
OBCIEmitterEot: obciEmitterEot,
OBCIEmitterError: obciEmitterError,
+ OBCIEmitterHardSet: obciEmitterHardSet,
OBCIEmitterImpedanceArray: obciEmitterImpedanceArray,
OBCIEmitterQuery: obciEmitterQuery,
OBCIEmitterRawDataPacket: obciEmitterRawDataPacket,
@@ -448,7 +448,7 @@ describe('OpenBCIConstants', function () {
assert.equal('daisy removed', k.OBCIChannelMaxNumber8SuccessDaisyRemoved);
assert.equal('16', k.OBCIChannelMaxNumber16DaisyAlreadyAttached);
assert.equal('daisy attached16', k.OBCIChannelMaxNumber16DaisyAttached);
- assert.equal('no daisy to attach!', k.OBCIChannelMaxNumber16NoDaisyAttached);
+ assert.equal('no daisy to attach!8', k.OBCIChannelMaxNumber16NoDaisyAttached);
});
});
describe('On board filters', function () {
@@ -1453,6 +1453,9 @@ describe('OpenBCIConstants', function () {
it('Event Emitter Error', function () {
assert.equal('error', k.OBCIEmitterError);
});
+ it('Event Emitter Hard Set', function () {
+ assert.equal('hardSet', k.OBCIEmitterHardSet);
+ });
it('Event Emitter Impedance Array', function () {
assert.equal('impedanceArray', k.OBCIEmitterImpedanceArray);
});
Oops, something went wrong.

0 comments on commit c2958f4

Please sign in to comment.