forked from andrewjaykeller/OpenBCI_NodeJS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
39 lines (33 loc) · 1.19 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var OpenBCISample = require('./OpenBCISample');
var OpenBCIBoard = require('./OpenBCIBoard');
var ourBoard = new OpenBCIBoard.OpenBCIBoard();
ourBoard.autoFindOpenBCIBoard(function(portName,ports) {
if(portName) {
ourBoard.boardConnect(portName).then(function(boardSerial) {
console.log('board connected');
ourBoard.on('ready',function() {
console.log('Ready to start streaming!');
ourBoard.streamStart();
ourBoard.on('sample',function(sample) {
OpenBCISample.debugPrettyPrint(sample);
});
});
}).catch(function(err) {
console.log('Error [setup]: ' + err);
});
} else {
/** Display list of ports*/
console.log('Port not found... check ports for other ports');
}
});
process.on('SIGINT', function() {
console.log("Caught interrupt signal");
ourBoard.debugSession();
ourBoard.boardDisconnect().then(function(success){
console.log('Serial port closed in the nic of time!');
process.exit();
}, function(error) {
console.log('No serial port to close...');
process.exit();
});
});