Last active
December 20, 2015 21:48
-
-
Save bencevans/6199906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var child_process = require('child_process'); | |
var LineInputStream = require('line-input-stream'); | |
var sensorex = LineInputStream(child_process.spawn('./sensorex')); | |
sensorex.setEncoding("utf8"); | |
sensorex.setDelimiter("\n"); | |
sensorex.on('line', function(line) { | |
console.log('New Line: ' + line); | |
var line = line.split('|'); | |
var line = { | |
letter: line[0], | |
accX: parseInt(line[1], 10), | |
accY: parseInt(line[2], 10), | |
accZ: parseInt(line[3], 10), | |
orX: parseInt(line[4], 10), | |
orY: parseInt(line[5], 10), | |
orZ: parseInt(line[6], 10) | |
}; | |
console.log('Line Obj:' , line); | |
}) | |
sensorex.on('error', function(err) { | |
console.log('sensorex err', err); | |
}) | |
sensorex.on('exit', function(exitcode) { | |
console.log('Exited with code ' + exitcode); | |
}); | |
//split on | | |
// letter, accX, accY, accZ, orX, orY, orZ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment