Permalink
Browse files

Merge pull request #136 from aj-ptw/fix-16-chan

Fix 16 chan
  • Loading branch information...
2 parents 70a6165 + 2523f72 commit 3f42be4df6def461c9ee101ff22ad6b4dbaa3f04 @aj-ptw aj-ptw committed on GitHub Jan 4, 2017
View
@@ -73,7 +73,7 @@ Want to know if the module really works? Check out some projects and organizatio
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.
-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!
+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!
Python researcher or developer? Check out how easy it is to [get access to the entire API in the Python example](examples/python)!
@@ -88,6 +88,7 @@ Initializing the board:
var OpenBCIBoard = require('openbci');
var ourBoard = new OpenBCIBoard.OpenBCIBoard();
```
+Go [checkout out the get streaming example](examples/getStreaming/getStreaming.js)!
For initializing with options, such as verbose print outs:
@@ -107,6 +108,16 @@ var ourBoard = new OpenBCIBoard({
});
```
+Have a daisy?:
+```js
+var OpenBCIBoard = require('openbci').OpenBCIBoard;
+var ourBoard = new OpenBCIBoard({
+ boardType: `daisy`,
+ hardSet: true
+});
+```
+Go [checkout out the get streaming with daisy example](examples/getStreamingDaisy/getStreamingDaisy.js)!
+
Another useful way to start the simulator:
```js
var openBCIBoard = require('openbci');
@@ -130,7 +141,7 @@ var ourBoard = new OpenBCIBoard({
simulate: true
});
```
-ps: go [checkout out the example](examples/debug/debug.js) to do it right now!
+Go [checkout out the debug example](examples/debug/debug.js)!
'ready' event
------------
@@ -395,6 +406,7 @@ Board optional configurations.
* `daisy` - 8 Channel board with Daisy Module - 16 Channels
* `ganglion` - 4 Channel board
(NOTE: THIS IS IN-OP TIL RELEASE OF GANGLION BOARD 08/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`)
* `simulatorBoardFailure` {Boolean} - Simulates board communications failure. This occurs when the RFduino on the board is not polling the RFduino on the dongle. (Default `false`)
* `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
**_Returns_** a promise, fulfilled if the command was sent to the board and the `.processBytes()` function is ready to reach for the specified channel.
+### <a name="method-hard-set-board-type"></a> .hardSetBoardType(boardType)
+
+Used to sync the module and board to `boardType`.
+
+**Note: This has the potential to change the way data is parsed**
+
+**_boardType_**
+
+A String indicating the number of channels.
+
+* `default` - Default board: Sample rate is `250Hz` and number of channels is `8`.
+* `daisy` - Daisy board: Sample rate is `125Hz` and number of channels is `16`.
+
+**_Returns_** a promise, fulfilled if both the board and module are the requested `boardType`, rejects otherwise.
+
### <a name="method-impedance-test-all-channels"></a> .impedanceTestAllChannels()
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).
**_Returns_** a number, the total number of available channels.
+### <a name="method-override-info-for-board-type"></a> .overrideInfoForBoardType(boardType)
+
+Set the info property for board type.
+
+**Note: This has the potential to change the way data is parsed**
+
+**_boardType_**
+
+A String indicating the number of channels.
+
+* `default` - Default board: Sample rate is `250Hz` and number of channels is `8`.
+* `daisy` - Daisy board: Sample rate is `125Hz` and number of channels is `16`.
+
### <a name="method-print-bytes-in"></a> .printBytesIn()
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
**_Returns_** resolves if the command was added to the write queue.
-### <a name="method-set-info-for-board-type"></a> .setInfoForBoardType(boardType)
-
-Set the info property for board type.
-
-**Note: This has the potential to change the way data is parsed**
-
-**_boardType_**
-
-A String indicating the number of channels.
-
-* `default` - Default board: Sample rate is `250Hz` and number of channels is `8`.
-* `daisy` - Daisy board: Sample rate is `125Hz` and number of channels is `16`.
-
-**_Returns_** a promise, fulfilled if the command was sent to the write queue. Rejects if input is not `8` or `16`.
-
-### <a name="method-set-max-channels"></a> .setMaxChannels(numberOfChannels)
-
-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.
-
-**_numberOfChannels_**
-
-A Number indicating the number of channels.
-
-* `8` - Default number of channels.
-* `16` - Daisy number of channels.
-
-**_Returns_** a promise, fulfilled if the command was sent to the write queue. Rejects if input is not `8` or `16`.
-
### <a name="method-simulator-enable"></a> .simulatorEnable()
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.
Emitted when there is an on the serial port.
+### <a name="event-hard-set"></a> .on('hardSet', callback)
+
+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.
+
### <a name="event-impedance-array"></a> .on('impedanceArray', callback)
Emitted when there is a new impedanceArray available. Returns an array.
View
@@ -1,9 +1,27 @@
+# 1.5.0
+
+### 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.
+* Add example for streaming with `daisy` and `hardSet`.
+
+### 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.
+
+### Enhancements
+* Separated radio tests from main board test file.
+
# 1.4.4
### New Features
* Set max number of channels for the board to use with `.setMaxChannels()` see readme.md
-* Set the core info object that drives the module with `.setInfoForBoardType()` see readme.md
-* Get info for the core obhect that drives the module with `.getInfo()` see readme.md
+* Set the core info object that drives the module with `.overrideInfoForBoardType()` see readme.md
+* Get info for the core object that drives the module with `.getInfo()` see readme.md
### Work In Progress
* Bug where daisy would sometimes not be recognized which destroyed all data.
@@ -0,0 +1,93 @@
+/**
+ * This is an example from the readme.md
+ * On windows you should run with PowerShell not git bash.
+ * Install
+ * [nodejs](https://nodejs.org/en/)
+ *
+ * To run:
+ * change directory to this file `cd examples/debug`
+ * do `npm install`
+ * then `npm start`
+ */
+var debug = false; // Pretty print any bytes in and out... it's amazing...
+var verbose = true; // Adds verbosity to functions
+
+var OpenBCIBoard = require('openbci').OpenBCIBoard;
+var ourBoard = new OpenBCIBoard({
+ boardType: 'daisy',
+ debug: debug,
+ hardSet: true,
+ verbose: verbose
+});
+
+ourBoard.on('error', (err) => {
+ console.log(err);
+});
+
+ourBoard.autoFindOpenBCIBoard().then(portName => {
+ if (portName) {
+ /**
+ * Connect to the board with portName
+ * Only works if one board is plugged in
+ * i.e. ourBoard.connect(portName).....
+ */
+ ourBoard.connect(portName) // Port name is a serial port name, see `.listPorts()`
+ .then(() => {
+ ourBoard.once('ready',() => {
+ ourBoard.streamStart();
+ ourBoard.on('sample',(sample) => {
+ /** Work with sample */
+ for (var i = 0; i < ourBoard.numberOfChannels(); i++) {
+ console.log("Channel " + (i + 1) + ": " + sample.channelData[i].toFixed(8) + " Volts.");
+ // prints to the console
+ // "Channel 1: 0.00001987 Volts."
+ // "Channel 2: 0.00002255 Volts."
+ // ...
+ // "Channel 16: -0.00001875 Volts."
+ }
+ });
+ });
+ });
+ } else {
+ /** Unable to auto find OpenBCI board */
+ console.log('Unable to auto find OpenBCI board');
+ }
+});
+
+function exitHandler (options, err) {
+ if (options.cleanup) {
+ if (verbose) console.log('clean');
+ /** Do additional clean up here */
+ }
+ if (err) console.log(err.stack);
+ if (options.exit) {
+ if (verbose) console.log('exit');
+ ourBoard.disconnect().catch(console.log);
+ }
+}
+
+if (process.platform === "win32") {
+ const rl = require("readline").createInterface({
+ input: process.stdin,
+ output: process.stdout
+ });
+
+ rl.on("SIGINT", function () {
+ process.emit("SIGINT");
+ });
+}
+
+// do something when app is closing
+process.on('exit', exitHandler.bind(null, {
+ cleanup: true
+}));
+
+// catches ctrl+c event
+process.on('SIGINT', exitHandler.bind(null, {
+ exit: true
+}));
+
+// catches uncaught exceptions
+process.on('uncaughtException', exitHandler.bind(null, {
+ exit: true
+}));
@@ -0,0 +1,18 @@
+{
+ "name": "get-streaming-daisy",
+ "version": "1.0.0",
+ "description": "Get streaming with hard set daisy example",
+ "main": "getStreaming.js",
+ "scripts": {
+ "start": "node getStreamingDaisy.js",
+ "test": "echo \"Error: no test specified\" && exit 1"
+ },
+ "keywords": [
+ "get"
+ ],
+ "author": "AJ Keller",
+ "license": "MIT",
+ "dependencies": {
+ "openbci": "^1.5.0"
+ }
+}
Oops, something went wrong.

0 comments on commit 3f42be4

Please sign in to comment.