4 Commits

Autor SHA1 Mensagem Data
AJ Keller d9c673ca12 Merge pull request #31 from benjaminjnoack/libudev-dev
add libudev-dev to linux dependencies in README
2017-06-03 07:03:37 -04:00
Ben Noack dd767e56c7 add libudev-dev to linux dependencies in README 2017-06-03 01:04:05 -04:00
AJ Keller 9071e4c630 Merge pull request #28 from aj-ptw/development
Addresses #27 - Adds delay between call to accel
2017-03-16 14:08:29 -04:00
AJ Keller e0fc689379 Addresses #27 - Adds delay between call to accel 2017-03-16 14:03:50 -04:00
3 arquivos alterados com 125 adições e 0 exclusões
+1
Ver Arquivo
@@ -70,6 +70,7 @@ Please ensure [Python 2.7 is installed](https://www.python.org/downloads/) for a
* Kernel version 3.6 or above
* ```libbluetooth-dev```
* ```libudev-dev```
### Windows 8+
+8
Ver Arquivo
@@ -1,3 +1,11 @@
# 0.4.4
### New Features
* LSL streaming example (thanks @gabrielibagon)
### Bug Fixes
* Fix #27 by adding delay
# 0.4.3
### Bug Fixes
+116
Ver Arquivo
@@ -0,0 +1,116 @@
const Ganglion = require('../../index').Ganglion;
const k = require('../../openBCIConstants');
const verbose = true;
let ganglion = new Ganglion({
debug: false,
verbose: verbose
}, (error) => {
if (error) {
console.log(error);
} else {
if (verbose) {
console.log('Ganglion initialize completed');
}
}
});
function errorFunc (err) {
throw err;
}
const accel = true;
ganglion.once(k.OBCIEmitterGanglionFound, (peripheral) => {
ganglion.searchStop().catch(errorFunc);
// ganglion.on('sample', (sample) => {
// console.log(sample.sampleNumber);
// });
ganglion.on('close', () => {
console.log('close event');
});
ganglion.on('message', (message) => {
console.log('message: ', message.toString());
});
ganglion.on('accelerometer', (accelData) => {
console.log('accelData', accelData);
});
ganglion.once('ready', () => {
if (accel) {
ganglion.accelStart()
.then(() => {
setTimeout(() => {
return ganglion.streamStart();
}, 60); // Delay until firmware is fixed.
})
.catch(errorFunc);
} else {
ganglion.streamStart().catch(errorFunc);
}
});
ganglion.connect(peripheral).catch(errorFunc);
});
function exitHandler (options, err) {
if (options.cleanup) {
if (verbose) console.log('clean');
// console.log(connectedPeripheral)
ganglion.manualDisconnect = true;
ganglion.disconnect();
ganglion.removeAllListeners('droppedPacket');
ganglion.removeAllListeners('accelerometer');
ganglion.removeAllListeners('sample');
ganglion.removeAllListeners('message');
ganglion.removeAllListeners('impedance');
ganglion.removeAllListeners('close');
ganglion.removeAllListeners('error');
ganglion.removeAllListeners('ganglionFound');
ganglion.removeAllListeners('ready');
ganglion.destroyNoble();
}
if (err) console.log(err.stack);
if (options.exit) {
if (verbose) console.log('exit');
if (ganglion.isSearching()) {
ganglion.searchStop().catch(console.log);
}
if (accel) {
ganglion.accelStop().catch(console.log);
}
ganglion.manualDisconnect = true;
ganglion.disconnect(true).catch(console.log);
process.exit(0);
}
}
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
}));