Comparar commits

...

10 Commits

Autor SHA1 Mensagem Data
AJ Keller 595c6dea5a Add: Coverage over sampleRate and numberOfChannels when info property is null 2016-12-05 10:48:17 -05:00
AJ Keller 89b5f35abc Add test for testSignal function 2016-12-05 10:48:17 -05:00
AJ Keller 9dd090df44 Add: test for print register settings 2016-12-05 10:47:52 -05:00
AJ Keller 8993a6c23b Enh: Drop factory Add: index.js Remove: Node 4 and 5 support 2016-12-05 10:47:52 -05:00
AJ Keller 888be5d60f Merge pull request #132 from aj-ptw/add-exp-python
Remove simulator line from python example
2016-12-05 10:29:56 -05:00
AJ Keller 57e6d9f7c2 Remove simulator line from python example 2016-12-05 10:26:39 -05:00
AJ Keller fb3d722fc8 Update package.json 2016-12-02 02:34:29 -05:00
AJ Keller 2728617126 Update readme.md 2016-12-02 02:34:09 -05:00
AJ Keller dd7639829a Update readme.md 2016-12-02 02:33:27 -05:00
AJ Keller b11775ecde Update README.md 2016-12-02 02:16:56 -05:00
20 arquivos alterados com 3060 adições e 2920 exclusões
+2 -7
Ver Arquivo
@@ -1,12 +1,5 @@
language: node_js
node_js:
- "4.0"
- "4.1"
- "4.2"
- "4.3"
- "4.4"
- "4.5"
- "4.6"
- "5.11.0"
- "6.0"
- "6.1"
@@ -17,6 +10,8 @@ node_js:
- "6.6"
- "6.7"
- "6.8"
- "7.0"
- "7.1"
install:
- npm install --all
script:
+303 -297
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+31 -1
Ver Arquivo
@@ -1,3 +1,33 @@
# 2.0.0
### New Features
* `index.js` file allows for ES6 destructing
### Breaking Changes
* Change name of `OpenBCIBoard` to `Cyton` to follow new naming convention.
Simply change:
```ecmascript 6
const OpenBCIBoard = require('openbci').OpenBCIBoard;
const ourBoard = new OpenBCIBoard();
```
```ecmascript 6
const Cyton = require('openbci').Cyton;
const ourBoard = new Cyton();
```
* Major change to how board is initialized with removal of `factory` paradigm.
* Drop support for Node 4 and 5 due to lack of EMACS 6
### Bug Fixes
* Documentation error with `testSignal` function.
### Enhancements
* Add more tests for public API functions.
# 1.4.3
### New examples
* Add example of node to python
# 1.4.2
### New examples
@@ -232,7 +262,7 @@ The second major release for the OpenBCI Node.js SDK brings major changes, impro
### Bug Fixes
* updates to README.me and comments to change ntp to sntp, because the two are similar, but not the same and we do not want to be misleading
* Extended [Stnp](https://www.npmjs.com/package/sntp) to main openBCIBoard.js
* Extended [Stnp](https://www.npmjs.com/package/sntp) to main openBCICyton.js
* Add `.sntpNow()` function to get ntp time.
# 0.3.1
+1 -1
Ver Arquivo
@@ -18,7 +18,7 @@ var debug = false; // Pretty print any bytes in and out... it's amazing...
var verbose = true; // Adds verbosity to functions
var ourBoard = new OpenBCIBoard({
simulate: simulate,
// simulate: simulate, // Uncomment to see how it works with simulator!
simulatorFirmwareVersion: 'v2',
debug: debug,
verbose: verbose
-1
Ver Arquivo
@@ -6,7 +6,6 @@
"scripts": {
"start": "concurrently --kill-others \"python handoff.py\" \"node index.js\"",
"start-node": "node index.js",
"start-verbose": "concurrently --kill-others \"python handoff.py -v\" \"node index.js\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
+3 -6
Ver Arquivo
@@ -10,7 +10,8 @@ This module has every feature available on the OpenBCI Board.
* [Python 2.7](https://www.python.org/downloads/)
* [ZeroMQ](http://zeromq.org/bindings:python)
```python
```py
pip install pyzmq
```
* [Node.js LTS](https://nodejs.org/en/)
@@ -30,14 +31,10 @@ npm install
```
npm start
```
Verbose:
```
npm run start-verbose
```
For running just the node, for example if you were running the python in a separate ide and debugging, it's useful.
```python
npm run start-node
```
## Contributing
Please PR if you have code to contribute!
Please PR if you have code to contribute!
+39
Ver Arquivo
@@ -29,6 +29,7 @@ ourBoard.autoFindOpenBCIBoard().then(portName => {
});
} else {
/** Unable to auto find OpenBCI board */
console.log('Unable to auto find OpenBCI board');
}
});
@@ -86,3 +87,41 @@ var sampleFunc = sample => {
// Subscribe to your functions
ourBoard.on('ready', readyFunc);
ourBoard.on('sample', sampleFunc);
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
}));
+2
Ver Arquivo
@@ -0,0 +1,2 @@
module.exports.Cyton = require('./openBCICyton');
module.exports.Constants = require('./openBCIConstants');
-2407
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+12
Ver Arquivo
@@ -203,6 +203,7 @@ const obciSimulatorFragmentationNone = 'none';
/** Possible Sample Rates */
const obciSampleRate125 = 125;
const obciSampleRate200 = 200;
const obciSampleRate250 = 250;
/** Max sample number */
@@ -232,9 +233,13 @@ const obciByteStart = 0xA0;
const obciByteStop = 0xC0;
/** Errors */
const errorNobleAlreadyScanning = 'Scan already under way';
const errorNobleNotAlreadyScanning = 'No scan started';
const errorNobleNotInPoweredOnState = 'Please turn blue tooth on.';
const errorInvalidByteLength = 'Invalid Packet Byte Length';
const errorInvalidByteStart = 'Invalid Start Byte';
const errorInvalidByteStop = 'Invalid Stop Byte';
const errorInvalidType = 'Invalid Type';
const errorTimeSyncIsNull = "'this.sync.curSyncObj' must not be null";
const errorTimeSyncNoComma = 'Missed the time sync sent confirmation. Try sync again';
const errorUndefinedOrNullInput = 'Undefined or Null Input';
@@ -337,6 +342,7 @@ const obciEmitterClose = 'close';
const obciEmitterDroppedPacket = 'droppedPacket';
const obciEmitterError = 'error';
const obciEmitterImpedanceArray = 'impedanceArray';
const obciEmitterMessage = 'message';
const obciEmitterQuery = 'query';
const obciEmitterRawDataPacket = 'rawDataPacket';
const obciEmitterReady = 'ready';
@@ -749,6 +755,7 @@ module.exports = {
},
/** Possible Sample Rates */
OBCISampleRate125: obciSampleRate125,
OBCISampleRate200: obciSampleRate200,
OBCISampleRate250: obciSampleRate250,
/** Max sample number */
OBCISampleNumberMax: obciSampleNumberMax,
@@ -758,9 +765,13 @@ module.exports = {
OBCIByteStart: obciByteStart,
OBCIByteStop: obciByteStop,
/** Errors */
OBCIErrorNobleAlreadyScanning: errorNobleAlreadyScanning,
OBCIErrorNobleNotAlreadyScanning: errorNobleNotAlreadyScanning,
OBCIErrorNobleNotInPoweredOnState: errorNobleNotInPoweredOnState,
OBCIErrorInvalidByteLength: errorInvalidByteLength,
OBCIErrorInvalidByteStart: errorInvalidByteStart,
OBCIErrorInvalidByteStop: errorInvalidByteStop,
OBCIErrorInvalidType: errorInvalidType,
OBCIErrorTimeSyncIsNull: errorTimeSyncIsNull,
OBCIErrorTimeSyncNoComma: errorTimeSyncNoComma,
OBCIErrorUndefinedOrNullInput: errorUndefinedOrNullInput,
@@ -896,6 +907,7 @@ module.exports = {
OBCIEmitterDroppedPacket: obciEmitterDroppedPacket,
OBCIEmitterError: obciEmitterError,
OBCIEmitterImpedanceArray: obciEmitterImpedanceArray,
OBCIEmitterMessage: obciEmitterMessage,
OBCIEmitterQuery: obciEmitterQuery,
OBCIEmitterRawDataPacket: obciEmitterRawDataPacket,
OBCIEmitterReady: obciEmitterReady,
+2351
Ver Arquivo
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+4 -4
Ver Arquivo
@@ -1,7 +1,7 @@
'use strict';
var gaussian = require('gaussian');
var k = require('./openBCIConstants');
var StreamSearch = require('streamsearch');
const gaussian = require('gaussian');
const k = require('./openBCIConstants');
const StreamSearch = require('streamsearch');
/** Constants for interpreting the EEG data */
// Reference voltage for ADC in ADS1299.
@@ -274,7 +274,7 @@ var sampleModule = {
return (prefix << 16) | (twoByteBuffer[0] << 8) | twoByteBuffer[1];
},
interpret24bitAsInt32: threeByteBuffer => {
interpret24bitAsInt32: (threeByteBuffer) => {
var prefix = 0;
if (threeByteBuffer[0] > 127) {
+1 -1
Ver Arquivo
@@ -120,7 +120,7 @@ function OpenBCISimulatorFactory () {
if (size > this.outputBuffered) size = this.outputBuffered;
// buffer is copied because presently openBCIBoard.js reuses it
// buffer is copied because presently openBCICyton.js reuses it
var outBuffer = new Buffer(this.outputBuffer.slice(0, size));
this.outputBuffer.copy(this.outputBuffer, 0, size, this.outputBuffered);
+35
Ver Arquivo
@@ -0,0 +1,35 @@
module.exports = {
debugBytes
};
/**
* @description Output passed bytes on the console as a hexdump, if enabled
* @param prefix - label to show to the left of bytes
* @param data - bytes to output, a buffer or string
* @private
*/
function debugBytes (prefix, data) {
if (typeof data === 'string') data = new Buffer(data);
console.log('Debug bytes:');
for (var j = 0; j < data.length;) {
var hexPart = '';
var ascPart = '';
for (var end = Math.min(data.length, j + 16); j < end; ++j) {
var byt = data[j];
var hex = ('0' + byt.toString(16)).slice(-2);
hexPart += (((j & 0xf) === 0x8) ? ' ' : ' '); // puts an extra space 8 bytes in
hexPart += hex;
var asc = (byt >= 0x20 && byt < 0x7f) ? String.fromCharCode(byt) : '.';
ascPart += asc;
}
// pad to fixed width for alignment
hexPart = (hexPart + ' ').substring(0, 3 * 17);
console.log(prefix + ' ' + hexPart + '|' + ascPart + '|');
}
}
+6 -3
Ver Arquivo
@@ -1,8 +1,8 @@
{
"name": "openbci",
"version": "1.4.2",
"version": "2.0.0",
"description": "The official Node.js SDK for the OpenBCI Biosensor Board.",
"main": "openBCIBoard",
"main": "index.js",
"scripts": {
"start": "node index",
"test": "semistandard | snazzy && mocha test",
@@ -16,10 +16,12 @@
"license": "MIT",
"dependencies": {
"buffer-equal": "^1.0.0",
"clone": "^2.0.0",
"gaussian": "^1.0.0",
"lodash": "^4.16.6",
"mathjs": "^3.3.0",
"performance-now": "^0.2.0",
"serialport": "4.0.1",
"serialport": "4.0.6",
"sntp": "^2.0.0",
"streamsearch": "^0.1.2"
},
@@ -53,6 +55,7 @@
"semistandard": {
"globals": [
"describe",
"xdescribe",
"context",
"before",
"beforeEach",
+6 -3
Ver Arquivo
@@ -764,6 +764,9 @@ describe('OpenBCIConstants', function () {
it('should be 125', function () {
assert.equal(125, k.OBCISampleRate125);
});
it('should be 250', function () {
assert.equal(200, k.OBCISampleRate200);
});
it('should be 250', function () {
assert.equal(250, k.OBCISampleRate250);
});
@@ -1446,6 +1449,9 @@ describe('OpenBCIConstants', function () {
it('Event Emitter Impedance Array', function () {
assert.equal('impedanceArray', k.OBCIEmitterImpedanceArray);
});
it('Event Emitter Message', function () {
assert.equal('message', k.OBCIEmitterMessage);
});
it('Event Emitter Query', function () {
assert.equal('query', k.OBCIEmitterQuery);
});
@@ -1459,7 +1465,4 @@ describe('OpenBCIConstants', function () {
assert.equal('sample', k.OBCIEmitterSample);
});
});
describe('Errors', function () {
});
});
+35 -35
Ver Arquivo
@@ -2,28 +2,28 @@
* Created by ajk on 12/15/15.
*/
'use strict';
var bluebirdChecks = require('./bluebirdChecks');
var openBCISample = require('../openBCISample');
var chai = require('chai');
var expect = chai.expect;
var assert = chai.assert;
var should = chai.should(); // eslint-disable-line no-unused-vars
const bluebirdChecks = require('./bluebirdChecks');
const openBCISample = require('../openBCISample');
const chai = require('chai');
const expect = chai.expect;
const assert = chai.assert;
const should = chai.should(); // eslint-disable-line no-unused-vars
var chaiAsPromised = require('chai-as-promised');
var sinonChai = require('sinon-chai');
const chaiAsPromised = require('chai-as-promised');
const sinonChai = require('sinon-chai');
chai.use(chaiAsPromised);
chai.use(sinonChai);
var bufferEqual = require('buffer-equal');
const bufferEqual = require('buffer-equal');
var k = openBCISample.k;
const k = require('../openBCIConstants');
const defaultChannelSettingsArray = k.channelSettingsArrayInit(k.OBCINumberOfChannelsDefault);
var sampleBuf = openBCISample.samplePacket();
const sampleBuf = openBCISample.samplePacket();
var accelArray;
let accelArray;
var channelScaleFactor = 4.5 / 24 / (Math.pow(2, 23) - 1);
const channelScaleFactor = 4.5 / 24 / (Math.pow(2, 23) - 1);
describe('openBCISample', function () {
beforeEach(function () {
@@ -600,28 +600,6 @@ describe('openBCISample', function () {
expect(sample.timeStamp).to.equal(time + timeOffset);
});
});
describe('#interpret24bitAsInt32', function () {
it('converts a small positive number', function () {
var buf1 = new Buffer([0x00, 0x06, 0x90]); // 0x000690 === 1680
var num = openBCISample.interpret24bitAsInt32(buf1);
assert.equal(num, 1680);
});
it('converts a large positive number', function () {
var buf1 = new Buffer([0x02, 0xC0, 0x01]); // 0x02C001 === 180225
var num = openBCISample.interpret24bitAsInt32(buf1);
assert.equal(num, 180225);
});
it('converts a small negative number', function () {
var buf1 = new Buffer([0xFF, 0xFF, 0xFF]); // 0xFFFFFF === -1
var num = openBCISample.interpret24bitAsInt32(buf1);
num.should.be.approximately(-1, 1);
});
it('converts a large negative number', function () {
var buf1 = new Buffer([0x81, 0xA1, 0x01]); // 0x81A101 === -8281855
var num = openBCISample.interpret24bitAsInt32(buf1);
num.should.be.approximately(-8281855, 1);
});
});
describe('#interpret16bitAsInt32', function () {
it('converts a small positive number', function () {
var buf1 = new Buffer([0x06, 0x90]); // 0x0690 === 1680
@@ -644,6 +622,28 @@ describe('openBCISample', function () {
assert.equal(num, -32351);
});
});
describe('#interpret24bitAsInt32', function () {
it('converts a small positive number', function () {
var buf1 = new Buffer([0x00, 0x06, 0x90]); // 0x000690 === 1680
var num = openBCISample.interpret24bitAsInt32(buf1);
assert.equal(num, 1680);
});
it('converts a large positive number', function () {
var buf1 = new Buffer([0x02, 0xC0, 0x01]); // 0x02C001 === 180225
var num = openBCISample.interpret24bitAsInt32(buf1);
assert.equal(num, 180225);
});
it('converts a small negative number', function () {
var buf1 = new Buffer([0xFF, 0xFF, 0xFF]); // 0xFFFFFF === -1
var num = openBCISample.interpret24bitAsInt32(buf1);
num.should.be.approximately(-1, 1);
});
it('converts a large negative number', function () {
var buf1 = new Buffer([0x81, 0xA1, 0x01]); // 0x81A101 === -8281855
var num = openBCISample.interpret24bitAsInt32(buf1);
num.should.be.approximately(-8281855, 1);
});
});
describe('#floatTo3ByteBuffer', function () {
it('converts random floats to a 3-byte buffer', function () {
var generateSample = openBCISample.randomSample(k.OBCINumberOfChannelsDefault, k.OBCISampleRate250);
@@ -1,13 +1,13 @@
'use strict';
var bluebirdChecks = require('./bluebirdChecks');
var chai = require('chai');
var should = chai.should(); // eslint-disable-line no-unused-vars
var openBCIBoard = require('../openBCIBoard');
var openBCISample = openBCIBoard.OpenBCISample;
var k = openBCISample.k;
const bluebirdChecks = require('./bluebirdChecks');
const chai = require('chai');
const should = chai.should(); // eslint-disable-line no-unused-vars
const Cyton = require('../openBCICyton');
const openBCISample = require('../openBCISample');
const k = openBCISample.k;
var chaiAsPromised = require('chai-as-promised');
var sinonChai = require('sinon-chai');
const chaiAsPromised = require('chai-as-promised');
const sinonChai = require('sinon-chai');
chai.use(chaiAsPromised);
chai.use(sinonChai);
@@ -16,7 +16,7 @@ describe('#impedanceTesting', function () {
this.timeout(20000);
before(function (done) {
ourBoard = new openBCIBoard.OpenBCIBoard({
ourBoard = new Cyton({
verbose: true,
simulatorFragmentation: k.OBCISimulatorFragmentationRandom
});
Diferenças do arquivo suprimidas por serem muito extensas Carregar Diff
+9 -9
Ver Arquivo
@@ -1,13 +1,13 @@
'use strict';
var bluebirdChecks = require('./bluebirdChecks');
var bufferEqual = require('buffer-equal');
var chai = require('chai');
var chaiAsPromised = require(`chai-as-promised`);
var expect = chai.expect;
var should = chai.should(); // eslint-disable-line no-unused-vars
var openBCISimulator = require('../openBCISimulator');
var openBCISample = require('../openBCISample');
var k = openBCISample.k;
const bluebirdChecks = require('./bluebirdChecks');
const bufferEqual = require('buffer-equal');
const chai = require('chai');
const chaiAsPromised = require(`chai-as-promised`);
const expect = chai.expect;
const should = chai.should(); // eslint-disable-line no-unused-vars
const openBCISimulator = require('../openBCISimulator');
const openBCISample = require('../openBCISample');
const k = require('../openBCIConstants');
chai.use(chaiAsPromised);