diff --git a/index.js b/index.js index a369127..bcab905 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,4 @@ // const { SerialPort } = require('serialport') - - - // // Create a port // const port = new SerialPort({ // path: '/com16/tty-usbserial1', @@ -18,7 +15,14 @@ // }) const { SerialPort } = require('serialport') const { ReadlineParser } = require('@serialport/parser-readline') -const port = new SerialPort({ path: '/com16/ROBOT', baudRate: 9600 }) +const port = new SerialPort({ path: '/com16', baudRate: 9600 }) + +var str = ""; const parser = port.pipe(new ReadlineParser({ delimiter: '\r\n' })) -parser.on('data', console.log) \ No newline at end of file +parser.on('data', (data) => { + if (str != data) { + console.log(data); + } + str = data; +}) \ No newline at end of file