// const { SerialPort } = require('serialport') // // Create a port // const port = new SerialPort({ // path: '/com16/tty-usbserial1', // baudRate: 9600, // }) // port.on('readable', function () { // console.log('Data:', port.read()) // }) // // Switches the port into "flowing mode" // port.on('data', function (data) { // console.log('Data:', data.toString('UTF8')) // }) const { SerialPort } = require('serialport') const { ReadlineParser } = require('@serialport/parser-readline') const port = new SerialPort({ path: '/com16/ROBOT', baudRate: 9600 }) const parser = port.pipe(new ReadlineParser({ delimiter: '\r\n' })) parser.on('data', console.log)