Skip to content

Instantly share code, notes, and snippets.

@Art2B
Created December 11, 2015 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Art2B/53a7f2e6d47bd688c83f to your computer and use it in GitHub Desktop.
Save Art2B/53a7f2e6d47bd688c83f to your computer and use it in GitHub Desktop.
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