Created
December 11, 2015 14:54
-
-
Save Art2B/53a7f2e6d47bd688c83f 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 SerialPort = require("serialport").SerialPort; | |
var serialPort = new SerialPort("/dev/ttyACM0", { | |
baudrate: 9600, | |
}); | |
var buffer; | |
serialPort.on("open", function () { | |
console.log('open'); | |
serialPort.on('data', function(data) { | |
buffer += data.toString('utf-8'); | |
if(buffer.indexOf(';') > -1){ | |
console.log('Here is your data:'+ buffer); | |
buffer = ''; | |
} | |
}); | |
serialPort.write("ls\n", function(err, results) { | |
console.log('err ' + err); | |
console.log('results ' + results); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment