Skip to content

Commit 3f42be4

Browse files
author
AJ Keller
authored
Merge pull request #136 from aj-ptw/fix-16-chan
Fix 16 chan
2 parents 70a6165 + 2523f72 commit 3f42be4

14 files changed

+1794
-1050
lines changed

README.md

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Want to know if the module really works? Check out some projects and organizatio
7373

7474
Still not satisfied it works?? Check out this [detailed report](http://s132342840.onlinehome.us/pushtheworld/files/voltageVerificationTestPlanAndResults.pdf) that scientifically validates the output voltages of this module.
7575

76-
How are you still doubting and not using this already? Fine, go look at some of the [700 **_automatic_** tests](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS) written for it!
76+
How are you still doubting and not using this already? Fine, go look at some of the [800 **_automatic_** tests](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS) written for it!
7777

7878
Python researcher or developer? Check out how easy it is to [get access to the entire API in the Python example](examples/python)!
7979

@@ -88,6 +88,7 @@ Initializing the board:
8888
var OpenBCIBoard = require('openbci');
8989
var ourBoard = new OpenBCIBoard.OpenBCIBoard();
9090
```
91+
Go [checkout out the get streaming example](examples/getStreaming/getStreaming.js)!
9192

9293
For initializing with options, such as verbose print outs:
9394

@@ -107,6 +108,16 @@ var ourBoard = new OpenBCIBoard({
107108
});
108109
```
109110

111+
Have a daisy?:
112+
```js
113+
var OpenBCIBoard = require('openbci').OpenBCIBoard;
114+
var ourBoard = new OpenBCIBoard({
115+
boardType: `daisy`,
116+
hardSet: true
117+
});
118+
```
119+
Go [checkout out the get streaming with daisy example](examples/getStreamingDaisy/getStreamingDaisy.js)!
120+
110121
Another useful way to start the simulator:
111122
```js
112123
var openBCIBoard = require('openbci');
@@ -130,7 +141,7 @@ var ourBoard = new OpenBCIBoard({
130141
simulate: true
131142
});
132143
```
133-
ps: go [checkout out the example](examples/debug/debug.js) to do it right now!
144+
Go [checkout out the debug example](examples/debug/debug.js)!
134145

135146
'ready' event
136147
------------
@@ -395,6 +406,7 @@ Board optional configurations.
395406
* `daisy` - 8 Channel board with Daisy Module - 16 Channels
396407
* `ganglion` - 4 Channel board
397408
(NOTE: THIS IS IN-OP TIL RELEASE OF GANGLION BOARD 08/2016)
409+
* `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`)
398410
* `simulate` {Boolean} - Full functionality, just mock data. Must attach Daisy module by setting `simulatorDaisyModuleAttached` to `true` in order to get 16 channels. (Default `false`)
399411
* `simulatorBoardFailure` {Boolean} - Simulates board communications failure. This occurs when the RFduino on the board is not polling the RFduino on the dongle. (Default `false`)
400412
* `simulatorDaisyModuleAttached` {Boolean} - Simulates a daisy module being attached to the OpenBCI board. This is useful if you want to test how your application reacts to a user requesting 16 channels but there is no daisy module actually attached, or vice versa, where there is a daisy module attached and the user only wants to use 8 channels. (Default `false`)
@@ -532,6 +544,21 @@ A number specifying which channel you want to get data on. Only 1-8 at this time
532544
533545
**_Returns_** a promise, fulfilled if the command was sent to the board and the `.processBytes()` function is ready to reach for the specified channel.
534546
547+
### <a name="method-hard-set-board-type"></a> .hardSetBoardType(boardType)
548+
549+
Used to sync the module and board to `boardType`.
550+
551+
**Note: This has the potential to change the way data is parsed**
552+
553+
**_boardType_**
554+
555+
A String indicating the number of channels.
556+
557+
* `default` - Default board: Sample rate is `250Hz` and number of channels is `8`.
558+
* `daisy` - Daisy board: Sample rate is `125Hz` and number of channels is `16`.
559+
560+
**_Returns_** a promise, fulfilled if both the board and module are the requested `boardType`, rejects otherwise.
561+
535562
### <a name="method-impedance-test-all-channels"></a> .impedanceTestAllChannels()
536563
537564
To apply test signals to the channels on the OpenBCI board used to test for impedance. This can take a little while to actually run (<8 seconds)!
@@ -721,6 +748,19 @@ Get the current number of channels available to use. (i.e. 8 or 16).
721748
722749
**_Returns_** a number, the total number of available channels.
723750
751+
### <a name="method-override-info-for-board-type"></a> .overrideInfoForBoardType(boardType)
752+
753+
Set the info property for board type.
754+
755+
**Note: This has the potential to change the way data is parsed**
756+
757+
**_boardType_**
758+
759+
A String indicating the number of channels.
760+
761+
* `default` - Default board: Sample rate is `250Hz` and number of channels is `8`.
762+
* `daisy` - Daisy board: Sample rate is `125Hz` and number of channels is `16`.
763+
724764
### <a name="method-print-bytes-in"></a> .printBytesIn()
725765
726766
Prints the total number of bytes that were read in this session to the console.
@@ -847,34 +887,6 @@ Stop logging to the SD card and close any open file. If you are not streaming wh
847887
848888
**_Returns_** resolves if the command was added to the write queue.
849889
850-
### <a name="method-set-info-for-board-type"></a> .setInfoForBoardType(boardType)
851-
852-
Set the info property for board type.
853-
854-
**Note: This has the potential to change the way data is parsed**
855-
856-
**_boardType_**
857-
858-
A String indicating the number of channels.
859-
860-
* `default` - Default board: Sample rate is `250Hz` and number of channels is `8`.
861-
* `daisy` - Daisy board: Sample rate is `125Hz` and number of channels is `16`.
862-
863-
**_Returns_** a promise, fulfilled if the command was sent to the write queue. Rejects if input is not `8` or `16`.
864-
865-
### <a name="method-set-max-channels"></a> .setMaxChannels(numberOfChannels)
866-
867-
Sends a command to the board to set the max channels. If you have a daisy attached, calling this function will re-sniff for the daisy ADS and attempt to use it.
868-
869-
**_numberOfChannels_**
870-
871-
A Number indicating the number of channels.
872-
873-
* `8` - Default number of channels.
874-
* `16` - Daisy number of channels.
875-
876-
**_Returns_** a promise, fulfilled if the command was sent to the write queue. Rejects if input is not `8` or `16`.
877-
878890
### <a name="method-simulator-enable"></a> .simulatorEnable()
879891
880892
To enter simulate mode. Must call [`.connect()`](#method-connect) after.
@@ -1114,6 +1126,10 @@ Emitted when a packet (or packets) are dropped. Returns an array.
11141126
11151127
Emitted when there is an on the serial port.
11161128
1129+
### <a name="event-hard-set"></a> .on('hardSet', callback)
1130+
1131+
Emitted 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.
1132+
11171133
### <a name="event-impedance-array"></a> .on('impedanceArray', callback)
11181134
11191135
Emitted when there is a new impedanceArray available. Returns an array.

changelog.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
# 1.5.0
2+
3+
### New Features
4+
* New simulator option `simulatorDaisyModuleCanBeAttached` - Boolean, deafults to true, allows the simulation of the a hot swapped daisy board or simulates a misinformed module.
5+
* 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.
6+
* Add example for streaming with `daisy` and `hardSet`.
7+
8+
### Breaking changes
9+
* `.setInfoForBoardType()` changed to `.overrideInfoForBoardType()` to elevate it's dangerous nature.
10+
* `.setMaxChannels()` changed to `.hardSetBoardType()` and input changed from numerical to string: 8 and 16 to `default` and `daisy` respectively.
11+
12+
### Bug Fixes
13+
* Fixes #131 - 16 chan not working by sending a channel command and parsing the return.
14+
* Fixed bug where end of transmission characters would not be ejected from buffer.
15+
16+
### Enhancements
17+
* Separated radio tests from main board test file.
18+
119
# 1.4.4
220

321
### New Features
422
* Set max number of channels for the board to use with `.setMaxChannels()` see readme.md
5-
* Set the core info object that drives the module with `.setInfoForBoardType()` see readme.md
6-
* Get info for the core obhect that drives the module with `.getInfo()` see readme.md
23+
* Set the core info object that drives the module with `.overrideInfoForBoardType()` see readme.md
24+
* Get info for the core object that drives the module with `.getInfo()` see readme.md
725

826
### Work In Progress
927
* Bug where daisy would sometimes not be recognized which destroyed all data.
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/**
2+
* This is an example from the readme.md
3+
* On windows you should run with PowerShell not git bash.
4+
* Install
5+
* [nodejs](https://nodejs.org/en/)
6+
*
7+
* To run:
8+
* change directory to this file `cd examples/debug`
9+
* do `npm install`
10+
* then `npm start`
11+
*/
12+
var debug = false; // Pretty print any bytes in and out... it's amazing...
13+
var verbose = true; // Adds verbosity to functions
14+
15+
var OpenBCIBoard = require('openbci').OpenBCIBoard;
16+
var ourBoard = new OpenBCIBoard({
17+
boardType: 'daisy',
18+
debug: debug,
19+
hardSet: true,
20+
verbose: verbose
21+
});
22+
23+
ourBoard.on('error', (err) => {
24+
console.log(err);
25+
});
26+
27+
ourBoard.autoFindOpenBCIBoard().then(portName => {
28+
if (portName) {
29+
/**
30+
* Connect to the board with portName
31+
* Only works if one board is plugged in
32+
* i.e. ourBoard.connect(portName).....
33+
*/
34+
ourBoard.connect(portName) // Port name is a serial port name, see `.listPorts()`
35+
.then(() => {
36+
ourBoard.once('ready',() => {
37+
ourBoard.streamStart();
38+
ourBoard.on('sample',(sample) => {
39+
/** Work with sample */
40+
for (var i = 0; i < ourBoard.numberOfChannels(); i++) {
41+
console.log("Channel " + (i + 1) + ": " + sample.channelData[i].toFixed(8) + " Volts.");
42+
// prints to the console
43+
// "Channel 1: 0.00001987 Volts."
44+
// "Channel 2: 0.00002255 Volts."
45+
// ...
46+
// "Channel 16: -0.00001875 Volts."
47+
}
48+
});
49+
});
50+
});
51+
} else {
52+
/** Unable to auto find OpenBCI board */
53+
console.log('Unable to auto find OpenBCI board');
54+
}
55+
});
56+
57+
function exitHandler (options, err) {
58+
if (options.cleanup) {
59+
if (verbose) console.log('clean');
60+
/** Do additional clean up here */
61+
}
62+
if (err) console.log(err.stack);
63+
if (options.exit) {
64+
if (verbose) console.log('exit');
65+
ourBoard.disconnect().catch(console.log);
66+
}
67+
}
68+
69+
if (process.platform === "win32") {
70+
const rl = require("readline").createInterface({
71+
input: process.stdin,
72+
output: process.stdout
73+
});
74+
75+
rl.on("SIGINT", function () {
76+
process.emit("SIGINT");
77+
});
78+
}
79+
80+
// do something when app is closing
81+
process.on('exit', exitHandler.bind(null, {
82+
cleanup: true
83+
}));
84+
85+
// catches ctrl+c event
86+
process.on('SIGINT', exitHandler.bind(null, {
87+
exit: true
88+
}));
89+
90+
// catches uncaught exceptions
91+
process.on('uncaughtException', exitHandler.bind(null, {
92+
exit: true
93+
}));
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "get-streaming-daisy",
3+
"version": "1.0.0",
4+
"description": "Get streaming with hard set daisy example",
5+
"main": "getStreaming.js",
6+
"scripts": {
7+
"start": "node getStreamingDaisy.js",
8+
"test": "echo \"Error: no test specified\" && exit 1"
9+
},
10+
"keywords": [
11+
"get"
12+
],
13+
"author": "AJ Keller",
14+
"license": "MIT",
15+
"dependencies": {
16+
"openbci": "^1.5.0"
17+
}
18+
}

0 commit comments

Comments
 (0)