Created
August 12, 2016 14:40
-
-
Save codewithpassion/0a142c8b0fb749c2e3ef242377346abd 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' ); | |
var debug = require('debug')('foo'); | |
var uartPath = "/dev/ttyO1"; | |
var uartBaud = 115200; | |
var serialConnected =false; | |
serialPort = new SerialPort.SerialPort( uartPath, | |
{ | |
baudrate: 115200, | |
lock:true, | |
parity:'none', | |
dataBits: 8, | |
stopBits: 1, | |
parser: SerialPort.parsers.readline('\r','utf8') | |
// parser: SerialPort.parsers.readline( '\r\n' ) | |
} ); | |
serialPort.on( 'open', function() | |
{ | |
serialConnected = true; | |
debug('@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@'); | |
} ); | |
serialPort.on( 'close', function( data ) | |
{ | |
console.log( 'Serial port closed!' ); | |
serialConnected = false; | |
} ); | |
serialPort.on( 'data', function( data ) | |
{ | |
debug('data: ' + data.toString()); | |
} ); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Data from a readline parser is already a string