From 7a33d3f5b1207ac373ab086481a17070e7c64c36 Mon Sep 17 00:00:00 2001 From: mmcwilliams Date: Tue, 23 Jan 2018 11:41:42 -0500 Subject: [PATCH] Corrected serialport usage after update --- app/lib/arduino/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/lib/arduino/index.js b/app/lib/arduino/index.js index a7a1a54..cedd8b0 100644 --- a/app/lib/arduino/index.js +++ b/app/lib/arduino/index.js @@ -5,6 +5,7 @@ const Readline = SerialPort.parsers.Readline const exec = require('child_process').exec const parser = new Readline('') const newlineRe = new RegExp('\n', 'g') +const returnRe = new RegExp('\r', 'g') let eventEmitter const mcopy = {} @@ -122,14 +123,13 @@ mcopy.arduino.connect = function (serial, device, confirm, callback) { if (!confirm) { mcopy.arduino.serial[device].on('data', data => { let d = data.toString('utf8') - - d = d.replace(newlineRe, '') + d = d.replace(newlineRe, '').replace(returnRe, '') mcopy.arduino.end(d) }) } else { mcopy.arduino.serial[device].on('data', data => { let d = data.toString('utf8') - d = d.replace(newlineRe, '') + d = d.replace(newlineRe, '').replace(returnRe, '') mcopy.arduino.confirmEnd(d) }) } @@ -142,6 +142,7 @@ mcopy.arduino.connect = function (serial, device, confirm, callback) { mcopy.arduino.confirmExec = {}; mcopy.arduino.confirmEnd = function (data) { + //console.dir(data) if (data === mcopy.cfg.arduino.cmd.connect || data === mcopy.cfg.arduino.cmd.proj_identifier || data === mcopy.cfg.arduino.cmd.cam_identifier