Created
December 7, 2014 07:36
-
-
Save bathtimefish/e09da6992ad0ed6ad8ee to your computer and use it in GitHub Desktop.
EspruinoでTWE-Liteのデータ受信コマンドを表示する
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 options = { | |
tx:B6, // wired 3 Pin(RX) on TWE-Lite | |
rx:B7, // wired 10 Pin(TX) on TWE-Lite | |
bytesize:8, | |
parity:'none', | |
stopbits:1, | |
flow:'none' | |
}; | |
Serial1.setup(115200, options); | |
Serial1.on('data', function(data) { | |
printLine(data); | |
}); | |
// http://www.espruino.com/USART | |
var cmd = ''; | |
var printLine = function(data) { | |
cmd+=data; | |
var idx = cmd.indexOf("\r"); | |
while (idx>=0) { | |
var line = cmd.substr(0,idx); | |
console.log(line); | |
cmd = cmd.substr(idx+1); | |
idx = cmd.indexOf("\r"); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment