Skip to content

Commit 6786041

Browse files
author
AJ Keller
committed
ADD daisy
1 parent 623cbf2 commit 6786041

File tree

4 files changed

+80
-6
lines changed

4 files changed

+80
-6
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ node_js:
77
- "6.0"
88
- "6.1"
99
- "6.2"
10+
- "6.3"
1011
install:
1112
- npm install --all
1213
script:

openBCISimulator.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ function OpenBCISimulatorFactory() {
5050
if (options.sampleRate) {
5151
opts.sampleRate = options.sampleRate;
5252
} else {
53-
if (opts.daisy) {
54-
opts.sampleRate = k.OBCISampleRate125;
55-
} else {
56-
opts.sampleRate = k.OBCISampleRate250;
57-
}
53+
opts.sampleRate = k.OBCISampleRate250;
5854
}
5955
opts.serialPortFailure = options.serialPortFailure || _options.serialPortFailure;
6056
opts.verbose = options.verbose || _options.verbose;

test/openBCIBoard-test.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ describe('openbci-sdk',function() {
372372
});
373373
});
374374

375+
376+
375377
describe('#boardTests', function() {
376378
this.timeout(2000);
377379
before(function() {
@@ -2476,6 +2478,81 @@ describe('openbci-sdk',function() {
24762478

24772479
});
24782480

2481+
describe('#daisy', function () {
2482+
var ourBoard;
2483+
this.timeout(4000);
2484+
before(function (done) {
2485+
ourBoard = new openBCIBoard.OpenBCIBoard({
2486+
verbose:true,
2487+
simulatorFirmwareVersion: 'v2',
2488+
simulatorDaisyModuleAttached: true,
2489+
});
2490+
2491+
var useSim = () => {
2492+
ourBoard.simulatorEnable()
2493+
.then(() => {
2494+
console.log(`has daisy module: ${ourBoard.options.simulatorDaisyModuleAttached}`);
2495+
return ourBoard.connect(k.OBCISimulatorPortName);
2496+
})
2497+
.then(() => {
2498+
return ourBoard.softReset();
2499+
})
2500+
.catch(err => console.log(err));
2501+
};
2502+
ourBoard.autoFindOpenBCIBoard()
2503+
.then(portName => {
2504+
return setTimeout(() => {
2505+
console.log('Issuing connect');
2506+
ourBoard.connect(portName);
2507+
},500);
2508+
})
2509+
.catch((err) => {
2510+
useSim();
2511+
})
2512+
.then(() => {
2513+
//console.log('connected');
2514+
})
2515+
.catch(err => {
2516+
console.log('Error: ' + err);
2517+
});
2518+
2519+
2520+
ourBoard.once('ready', () => {
2521+
done();
2522+
});
2523+
});
2524+
after(done => {
2525+
if (ourBoard.connected) {
2526+
ourBoard.disconnect().then(() => {
2527+
done();
2528+
}).catch(() => done);
2529+
} else {
2530+
done();
2531+
}
2532+
});
2533+
it("can get samples with channel array of length 16", done => {
2534+
var numberOfSamples = 130;
2535+
var sampleCount = 0;
2536+
var samp = sample => {
2537+
console.log(`sample`, sample);
2538+
// expect(sample.sampleNumber).to.equal(sampleCount);
2539+
expect(sample.channelData.length).to.equal(k.OBCINumberOfChannelsDaisy);
2540+
if (sampleCount <= numberOfSamples) {
2541+
sampleCount++;
2542+
} else {
2543+
ourBoard.disconnect()
2544+
.then(() => {
2545+
done();
2546+
});
2547+
ourBoard.removeListener('sample',samp);
2548+
}
2549+
};
2550+
ourBoard.on('sample',samp);
2551+
ourBoard.streamStart().catch(err => done);
2552+
// Attached the emitted
2553+
});
2554+
});
2555+
24792556
// Need a better test
24802557
describe('#sync', function() {
24812558
var ourBoard;

test/openBCISimulator-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe('openBCISimulator',function() {
5050
simulator = new openBCISimulator.OpenBCISimulator(portName,{
5151
daisy: true
5252
});
53-
expect(simulator.options.sampleRate).to.equal(125);
53+
expect(simulator.options.sampleRate).to.equal(250); // produce samples at same rate
5454
});
5555
it('should use provided sample rate even if daisy is true',function () {
5656
simulator = new openBCISimulator.OpenBCISimulator(portName,{

0 commit comments

Comments
 (0)