Skip to content

Commit

Permalink
Remove simulator line from python example
Browse files Browse the repository at this point in the history
  • Loading branch information
AJ Keller committed Dec 5, 2016
1 parent 4ce630d commit 57e6d9f
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 1 deletion.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ Still not satisfied it works?? Check out this [detailed report](http://s13234284

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!

Python researcher or developer? Check out how easy it is to [get access to the entire API in the Python example](examples/python)!

### <a name="general-overview"></a> General Overview:

Initialization
Expand Down
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# 1.4.3

### New examples
* Add example of node to python

# 1.4.2

### New examples
Expand Down
2 changes: 1 addition & 1 deletion examples/python/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
39 changes: 39 additions & 0 deletions examples/timeSync/timeSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ourBoard.autoFindOpenBCIBoard().then(portName => {
});
} else {
/** Unable to auto find OpenBCI board */
console.log('Unable to auto find OpenBCI board');
}
});

Expand Down Expand Up @@ -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
}));

0 comments on commit 57e6d9f

Please sign in to comment.