Created
December 20, 2016 04:15
-
-
Save Casear/cf01265bf857c223e1926e4f15ea4541 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/ttyS0", { | |
baudrate: 9600 | |
}); | |
serialPort.on("open", function() { | |
serialPort.on('data', function(data) { | |
console.log(data.toString()) | |
}) | |
var stdin = process.openStdin(); | |
stdin.addListener("data", function(d) { | |
serialPort.write(d.toString()+'\n') | |
console.log("you send: [" + d.toString().trim() + "]"); | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment