Skip to content

Instantly share code, notes, and snippets.

@codewithpassion
Created August 12, 2016 14:40
Show Gist options
  • Save codewithpassion/0a142c8b0fb749c2e3ef242377346abd to your computer and use it in GitHub Desktop.
Save codewithpassion/0a142c8b0fb749c2e3ef242377346abd to your computer and use it in GitHub Desktop.
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());
} );
@reconbot
Copy link

Data from a readline parser is already a string

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment