Skip to content

Instantly share code, notes, and snippets.

@bathtimefish
Created December 7, 2014 07:36
Show Gist options
  • Save bathtimefish/e09da6992ad0ed6ad8ee to your computer and use it in GitHub Desktop.
Save bathtimefish/e09da6992ad0ed6ad8ee to your computer and use it in GitHub Desktop.
EspruinoでTWE-Liteのデータ受信コマンドを表示する
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