Comparar commits
4 Commits
| Autor | SHA1 | Data | |
|---|---|---|---|
| b51cb54f92 | |||
| 19f05e362f | |||
| c33d08b486 | |||
| 97cff2dac9 |
@@ -2,6 +2,8 @@
|
||||
[](https://gitter.im/OpenBCI/OpenBCI_NodeJS?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://travis-ci.org/OpenBCI/OpenBCI_NodeJS)
|
||||
[](https://codecov.io/gh/OpenBCI/OpenBCI_NodeJS)
|
||||
[](https://david-dm.org/OpenBCI/OpenBCI_NodeJS)
|
||||
[](http://npmjs.com/package/openbci)
|
||||
|
||||
# OpenBCI Node.js SDK
|
||||
|
||||
|
||||
@@ -1,3 +1,15 @@
|
||||
# 1.2.2
|
||||
|
||||
### Enhancements
|
||||
|
||||
* Upgrade serialport to 4.x
|
||||
|
||||
# 1.2.1
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* Fixed bug where set channel function allowed for channel 0 to be set. Cannot set system to channel 0; lower limit is 1.
|
||||
|
||||
# 1.2.0
|
||||
|
||||
### New Features
|
||||
|
||||
+9
-9
@@ -3,7 +3,7 @@
|
||||
var EventEmitter = require('events').EventEmitter,
|
||||
util = require('util'),
|
||||
stream = require('stream'),
|
||||
serialPort = require('serialport'),
|
||||
SerialPort = require('serialport'),
|
||||
openBCISample = require('./openBCISample'),
|
||||
k = openBCISample.k,
|
||||
openBCISimulator = require('./openBCISimulator'),
|
||||
@@ -240,7 +240,7 @@ function OpenBCIFactory() {
|
||||
} else {
|
||||
/* istanbul ignore if */
|
||||
if (this.options.verbose) console.log('using real board ' + portName);
|
||||
boardSerial = new serialPort.SerialPort(portName, {
|
||||
boardSerial = new SerialPort(portName, {
|
||||
baudRate: this.options.baudRate
|
||||
},(err) => {
|
||||
if (err) reject(err);
|
||||
@@ -473,14 +473,14 @@ function OpenBCIFactory() {
|
||||
OpenBCIBoard.prototype._writeAndDrain = function(data) {
|
||||
return new Promise((resolve,reject) => {
|
||||
if(!this.serial) reject('Serial port not open');
|
||||
this.serial.write(data,(error,results) => {
|
||||
if(results) {
|
||||
this.serial.write(data,(error) => {
|
||||
if(error) {
|
||||
console.log('Error [writeAndDrain]: ' + error);
|
||||
reject(error);
|
||||
} else {
|
||||
this.serial.drain(function() {
|
||||
resolve();
|
||||
});
|
||||
} else {
|
||||
console.log('Error [writeAndDrain]: ' + error);
|
||||
reject(error);
|
||||
}
|
||||
})
|
||||
});
|
||||
@@ -504,7 +504,7 @@ function OpenBCIFactory() {
|
||||
if (this.options.verbose) console.log('auto found sim board');
|
||||
resolve(k.OBCISimulatorPortName);
|
||||
} else {
|
||||
serialPort.list((err, ports) => {
|
||||
SerialPort.list((err, ports) => {
|
||||
if(err) {
|
||||
if (this.options.verbose) console.log('serial port err');
|
||||
reject(err);
|
||||
@@ -921,7 +921,7 @@ function OpenBCIFactory() {
|
||||
*/
|
||||
OpenBCIBoard.prototype.listPorts = function() {
|
||||
return new Promise((resolve, reject) => {
|
||||
serialPort.list((err, ports) => {
|
||||
SerialPort.list((err, ports) => {
|
||||
if(err) reject(err);
|
||||
else {
|
||||
ports.push( {
|
||||
|
||||
@@ -306,7 +306,7 @@ const OBCISimulatorStandard = 'standard';
|
||||
|
||||
/** OpenBCI Radio Limits */
|
||||
const OBCIRadioChannelMax = 25;
|
||||
const OBCIRadioChannelMin = 0;
|
||||
const OBCIRadioChannelMin = 1;
|
||||
const OBCIRadioPollTimeMax = 255;
|
||||
const OBCIRadioPollTimeMin = 0;
|
||||
|
||||
|
||||
+3
-3
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "openbci",
|
||||
"version": "1.2.0",
|
||||
"version": "1.2.2",
|
||||
"description": "The official Node.js SDK for the OpenBCI Biosensor Board.",
|
||||
"main": "openBCIBoard",
|
||||
"scripts": {
|
||||
@@ -19,7 +19,7 @@
|
||||
"gaussian": "^1.0.0",
|
||||
"mathjs": "^3.3.0",
|
||||
"performance-now": "^0.2.0",
|
||||
"serialport": "3.1.2",
|
||||
"serialport": "4.0.1",
|
||||
"sntp": "^2.0.0",
|
||||
"streamsearch": "^0.1.2"
|
||||
},
|
||||
@@ -31,7 +31,7 @@
|
||||
"chai-as-promised": "^5.2.0",
|
||||
"codecov": "^1.0.1",
|
||||
"istanbul": "^0.4.4",
|
||||
"mocha": "^2.3.4",
|
||||
"mocha": "^3.0.2",
|
||||
"sandboxed-module": "^2.0.3",
|
||||
"sinon": "^1.17.2",
|
||||
"sinon-chai": "^2.8.0"
|
||||
|
||||
@@ -770,7 +770,7 @@ describe('OpenBCIConstants', function() {
|
||||
expect(k.OBCIRadioChannelMax).to.be.equal(25);
|
||||
});
|
||||
it("should get the right channel number min",function () {
|
||||
expect(k.OBCIRadioChannelMin).to.be.equal(0);
|
||||
expect(k.OBCIRadioChannelMin).to.be.equal(1);
|
||||
});
|
||||
it("should get the right poll time max",function () {
|
||||
expect(k.OBCIRadioPollTimeMax).to.be.equal(255);
|
||||
|
||||
@@ -400,9 +400,6 @@ describe('openbci-sdk',function() {
|
||||
}).catch(err => done(err));
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
describe('#boardTests', function() {
|
||||
this.timeout(3000);
|
||||
before(function() {
|
||||
@@ -2530,7 +2527,7 @@ describe('openbci-sdk',function() {
|
||||
});
|
||||
|
||||
describe('#radioTestsWithBoard',function() {
|
||||
this.timeout(3000);
|
||||
this.timeout(0);
|
||||
before(function(done) {
|
||||
ourBoard = new openBCIBoard.OpenBCIBoard({
|
||||
verbose: true
|
||||
@@ -2583,11 +2580,11 @@ describe('openbci-sdk',function() {
|
||||
done();
|
||||
}).catch(err => done(err));
|
||||
});
|
||||
it("should be able to set the channel to 0", function(done) {
|
||||
it("should be able to set the channel to 5", function(done) {
|
||||
// Don't test if not using real board
|
||||
if (!realBoard) return done();
|
||||
ourBoard.radioChannelSet(0).then(channelNumber => {
|
||||
expect(channelNumber).to.equal(0);
|
||||
ourBoard.radioChannelSet(5).then(channelNumber => {
|
||||
expect(channelNumber).to.equal(5);
|
||||
done();
|
||||
}).catch(err => done(err));
|
||||
});
|
||||
@@ -2596,11 +2593,13 @@ describe('openbci-sdk',function() {
|
||||
if (!realBoard) return done();
|
||||
var systemChanNumber = 0;
|
||||
var newChanNum = 0;
|
||||
// var timey = Date.now();
|
||||
// Get the current system channel
|
||||
ourBoard.radioChannelGet()
|
||||
.then(res => {
|
||||
// Store it
|
||||
systemChanNumber = res.channelNumber;
|
||||
// console.log(`system channel number: ${res.channelNumber}`);
|
||||
if (systemChanNumber == 25) {
|
||||
newChanNum = 24;
|
||||
} else {
|
||||
@@ -2611,9 +2610,24 @@ describe('openbci-sdk',function() {
|
||||
})
|
||||
.then(newChanNumActual => {
|
||||
expect(newChanNumActual).to.equal(newChanNum);
|
||||
return ourBoard.radioSystemStatusGet();
|
||||
// timey = Date.now();
|
||||
// console.log(`new chan ${newChanNumActual} got`, timey, '0ms');
|
||||
return new Promise((resolve, reject) => {
|
||||
setTimeout(function() {
|
||||
// console.log(`get status`, Date.now(), `${Date.now() - timey}ms`);
|
||||
ourBoard.radioSystemStatusGet().
|
||||
then(isUp => {
|
||||
// console.log('resolving', Date.now(), `${Date.now() - timey}ms`);
|
||||
resolve(isUp);
|
||||
})
|
||||
.catch(err => {
|
||||
reject(err);
|
||||
})
|
||||
}, 270); // Should be accurate after 270 seconds
|
||||
});
|
||||
})
|
||||
.then(isUp => {
|
||||
// console.log(`isUp test`, Date.now(), `${Date.now() - timey}ms`);
|
||||
expect(isUp).to.be.false;
|
||||
return ourBoard.radioChannelSetHostOverride(systemChanNumber); // Set back to good
|
||||
})
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário