Comparar commits

..

13 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
AJ Keller f96cdd94ec Merge pull request #130 from aj-ptw/add-exp-python
Add exp python
2016-12-02 02:14:51 -05:00
AJ Keller 4ce630dc4c Add: Python example 2016-12-02 02:14:08 -05:00
AJ Keller 8557444c55 1.4.2 2016-12-02 00:25:07 -05:00
22 arquivos alterados com 3466 adições e 2912 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
+117
Ver Arquivo
@@ -0,0 +1,117 @@
import json
import sys
import numpy as np
import time
import zmq
class Interface:
def __init__(self, verbose=False):
context = zmq.Context()
self._socket = context.socket(zmq.PAIR)
self._socket.connect("tcp://localhost:3004")
self.verbose = verbose
if self.verbose:
print "Client Ready!"
# Send a quick message to tell node process we are up and running
self.send(json.dumps({
'action': 'started',
'command': 'status',
'message': time.time()*1000.0
}))
def send(self, msg):
"""
Sends a message to TCP server
:param msg: str
A string to send to node TCP server, could be a JSON dumps...
:return: None
"""
if self.verbose:
print '<- out ' + msg
self._socket.send(msg)
return
def recv(self):
"""
Checks the ZeroMQ for data
:return: str
String of data
"""
return self._socket.recv()
class RingBuffer(np.ndarray):
"""A multidimensional ring buffer."""
def __new__(cls, input_array):
obj = np.asarray(input_array).view(cls)
return obj
def __array_finalize__(self, obj):
if obj is None:
return
def __array_wrap__(self, out_arr, context=None):
return np.ndarray.__array_wrap__(self, out_arr, context)
def append(self, x):
"""Adds element x to the ring buffer."""
x = np.asarray(x)
self[:, :-1] = self[:, 1:]
self[:, -1] = x
def main(argv):
nb_chan = 8
verbose = True
# Create a new python interface.
interface = Interface(verbose=verbose)
# Signal buffer
signal = RingBuffer(np.zeros((nb_chan + 1, 2500)))
while True:
msg = interface.recv()
try:
dicty = json.loads(msg)
action = dicty.get('action')
command = dicty.get('command')
message = dicty.get('message')
if command == 'sample':
if action == 'process':
# Do sample processing here
try:
if type(message) is not dict:
print "sample is not a dict", message
raise ValueError
# Get keys of sample
data = np.zeros(9)
data[:-1] = message.get('channelData')
data[-1] = message.get('timeStamp')
# Add data to end of ring buffer
signal.append(data)
print message.get('sampleNumber')
except ValueError as e:
print e
elif command == 'status':
if action == 'active':
interface.send(json.dumps({
'action': 'alive',
'command': 'status',
'message': time.time() * 1000.0
}))
except BaseException as e:
print e
if __name__ == '__main__':
main(sys.argv[1:])
+212
Ver Arquivo
@@ -0,0 +1,212 @@
/**
* 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 OpenBCIBoard = require('openbci').OpenBCIBoard;
var port_pub = 'tcp://127.0.0.1:3004';
var zmq = require('zmq-prebuilt');
var socket = zmq.socket('pair');
var simulate = true; // Sends synthetic data
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, // Uncomment to see how it works with simulator!
simulatorFirmwareVersion: 'v2',
debug: debug,
verbose: verbose
});
var sampleRate = 250; // Default to 250, ALWAYS verify with a call to `.sampleRate()` after 'ready' event!
var timeSyncPossible = false;
var resyncPeriodMin = 1;
var secondsInMinute = 60;
var resyncPeriod = ourBoard.sampleRate() * resyncPeriodMin * secondsInMinute;
ourBoard.autoFindOpenBCIBoard().then(portName => {
if (portName) {
/**
* Connect to the board with portName
* i.e. ourBoard.connect(portName).....
*/
// Call to connect
ourBoard.connect(portName)
.then(() => {
ourBoard.on('ready', () => {
// Get the sample rate after 'ready'
sampleRate = ourBoard.sampleRate();
// Find out if you can even time sync, you must be using v2 and this is only accurate after a `.softReset()` call which is called internally on `.connect()`. We parse the `.softReset()` response for the presence of firmware version 2 properties.
timeSyncPossible = ourBoard.usingVersionTwoFirmware();
if (timeSyncPossible) {
ourBoard.streamStart()
.catch(err => {
console.log(`stream start: ${err}`);
});
} else {
console.log('not able to time sync');
}
})
})
.catch(err => {
console.log(`connect: ${err}`);
});
} else {
/** Unable to auto find OpenBCI board */
console.log('Unable to auto find OpenBCI board');
}
});
var sampleFunc = sample => {
if (sample._count % resyncPeriod === 0) {
ourBoard.syncClocksFull()
.then(syncObj => {
// Sync was successful
if (syncObj.valid) {
// Log the object to check it out!
console.log(`timeOffset`, syncObj.timeOffsetMaster);
} else {
// Retry it
console.log(`Was not able to sync... retry!`);
}
});
}
if (sample.timeStamp) { // true after the first successful sync
if (sample.timeStamp < 10 * 60 * 60 * 1000) { // Less than 10 hours
console.log(`Bad time sync ${sample.timeStamp}`);
} else {
sendToPython({
action: 'process',
command: 'sample',
message: sample
});
}
}
};
// Subscribe to your functions
ourBoard.on('sample', sampleFunc);
// ZMQ fun
socket.bind(port_pub, function (err) {
if (err) throw err;
console.log(`bound to ${port_pub}`);
});
/**
* Used to send a message to the Python process.
* @param {Object} interProcessObject The standard inter-process object.
* @return {None}
*/
var sendToPython = (interProcessObject, verbose) => {
if (verbose) {
console.log(`<- out ${JSON.stringify(interProcessObject)}`);
}
if (socket) {
socket.send(JSON.stringify(interProcessObject));
}
};
var receiveFromPython = (raw_data) => {
try {
let body = JSON.parse(raw_data); // five because `resp `
processInterfaceObject(body);
} catch (err) {
console.log('in -> ' + 'bad json');
}
};
socket.on('message', receiveFromPython);
var sendStatus = () => {
sendToPython({'action': 'active', 'message': 'ready', 'command': 'status'}, true);
};
sendStatus();
/**
* Process an incoming message
* @param {String} body A stringify JSON object that shall be parsed.
* @return {None}
*/
var processInterfaceObject = (body) => {
switch (body.command) {
case 'status':
processStatus(body);
break;
default:
unrecognizedCommand(body);
break;
}
};
/**
* Used to process a status related command from TCP IPC.
* @param {Object} body
* @return {None}
*/
var processStatus = (body) => {
switch (body.action) {
case 'started':
console.log(`python started @ ${body.message}ms`);
break;
case 'alive':
console.log(`python duplex communication test completed @ ${body.message}ms`);
break;
default:
unrecognizedCommand(body);
break;
}
};
function unrecognizedCommand (body) {
console.log(`unrecognizedCommand ${body}`);
}
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
}));
+29
Ver Arquivo
@@ -0,0 +1,29 @@
{
"name": "python",
"version": "1.0.0",
"description": "node to python example",
"main": "index.js",
"scripts": {
"start": "concurrently --kill-others \"python handoff.py\" \"node index.js\"",
"start-node": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"python",
"openbci",
"node"
],
"author": "AJ Keller",
"license": "MIT",
"dependencies": {
"openbci": "^1.4.2",
"zmq-prebuilt": "^2.1.0"
},
"devEngines": {
"node": "<=6.x",
"npm": ">=3.x"
},
"devDependencies": {
"concurrently": "^3.1.0"
}
}
+40
Ver Arquivo
@@ -0,0 +1,40 @@
# OpenBCI Node SDK to Python
## About
Written to end the struggles of python researchers and developers. ~ written with love by [Push The World!](http://www.pushtheworldllc.com)
This module has every feature available on the OpenBCI Board.
## Prerequisites
* [Python 2.7](https://www.python.org/downloads/)
* [ZeroMQ](http://zeromq.org/bindings:python)
```py
pip install pyzmq
```
* [Node.js LTS](https://nodejs.org/en/)
## Installation
For Python 2.7 do:
```bash
python setup.py install
```
For Node:
```bash
npm install
```
## Running
```
npm start
```
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!
+12
Ver Arquivo
@@ -0,0 +1,12 @@
from setuptools import setup, find_packages
setup(name='openbci-node-python',
version='0.0.1',
description='Node to Python the right way',
url='',
author='AJ Keller',
author_email='pushtheworldllc@gmail.com',
license='MIT',
packages=find_packages(),
install_requires=['numpy', 'pyzmq'],
zip_safe=False)
+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.1",
"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);