Skip to content

Commit

Permalink
ADD daisy
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ Keller committed Jul 10, 2016
1 parent 623cbf2 commit 6786041
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 6 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ node_js:
- "6.0"
- "6.1"
- "6.2"
- "6.3"
install:
- npm install --all
script:
Expand Down
6 changes: 1 addition & 5 deletions openBCISimulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,7 @@ function OpenBCISimulatorFactory() {
if (options.sampleRate) {
opts.sampleRate = options.sampleRate;
} else {
if (opts.daisy) {
opts.sampleRate = k.OBCISampleRate125;
} else {
opts.sampleRate = k.OBCISampleRate250;
}
opts.sampleRate = k.OBCISampleRate250;
}
opts.serialPortFailure = options.serialPortFailure || _options.serialPortFailure;
opts.verbose = options.verbose || _options.verbose;
Expand Down
77 changes: 77 additions & 0 deletions test/openBCIBoard-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ describe('openbci-sdk',function() {
});
});



describe('#boardTests', function() {
this.timeout(2000);
before(function() {
Expand Down Expand Up @@ -2476,6 +2478,81 @@ describe('openbci-sdk',function() {

});

describe('#daisy', function () {
var ourBoard;
this.timeout(4000);
before(function (done) {
ourBoard = new openBCIBoard.OpenBCIBoard({
verbose:true,
simulatorFirmwareVersion: 'v2',
simulatorDaisyModuleAttached: true,
});

var useSim = () => {
ourBoard.simulatorEnable()
.then(() => {
console.log(`has daisy module: ${ourBoard.options.simulatorDaisyModuleAttached}`);
return ourBoard.connect(k.OBCISimulatorPortName);
})
.then(() => {
return ourBoard.softReset();
})
.catch(err => console.log(err));
};
ourBoard.autoFindOpenBCIBoard()
.then(portName => {
return setTimeout(() => {
console.log('Issuing connect');
ourBoard.connect(portName);
},500);
})
.catch((err) => {
useSim();
})
.then(() => {
//console.log('connected');
})
.catch(err => {
console.log('Error: ' + err);
});


ourBoard.once('ready', () => {
done();
});
});
after(done => {
if (ourBoard.connected) {
ourBoard.disconnect().then(() => {
done();
}).catch(() => done);
} else {
done();
}
});
it("can get samples with channel array of length 16", done => {
var numberOfSamples = 130;
var sampleCount = 0;
var samp = sample => {
console.log(`sample`, sample);
// expect(sample.sampleNumber).to.equal(sampleCount);
expect(sample.channelData.length).to.equal(k.OBCINumberOfChannelsDaisy);
if (sampleCount <= numberOfSamples) {
sampleCount++;
} else {
ourBoard.disconnect()
.then(() => {
done();
});
ourBoard.removeListener('sample',samp);
}
};
ourBoard.on('sample',samp);
ourBoard.streamStart().catch(err => done);
// Attached the emitted
});
});

// Need a better test
describe('#sync', function() {
var ourBoard;
Expand Down
2 changes: 1 addition & 1 deletion test/openBCISimulator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('openBCISimulator',function() {
simulator = new openBCISimulator.OpenBCISimulator(portName,{
daisy: true
});
expect(simulator.options.sampleRate).to.equal(125);
expect(simulator.options.sampleRate).to.equal(250); // produce samples at same rate
});
it('should use provided sample rate even if daisy is true',function () {
simulator = new openBCISimulator.OpenBCISimulator(portName,{
Expand Down

0 comments on commit 6786041

Please sign in to comment.