Corrected serialport usage after update
This commit is contained in:
parent
d311ac4727
commit
7a33d3f5b1
|
@ -5,6 +5,7 @@ const Readline = SerialPort.parsers.Readline
|
||||||
const exec = require('child_process').exec
|
const exec = require('child_process').exec
|
||||||
const parser = new Readline('')
|
const parser = new Readline('')
|
||||||
const newlineRe = new RegExp('\n', 'g')
|
const newlineRe = new RegExp('\n', 'g')
|
||||||
|
const returnRe = new RegExp('\r', 'g')
|
||||||
let eventEmitter
|
let eventEmitter
|
||||||
|
|
||||||
const mcopy = {}
|
const mcopy = {}
|
||||||
|
@ -122,14 +123,13 @@ mcopy.arduino.connect = function (serial, device, confirm, callback) {
|
||||||
if (!confirm) {
|
if (!confirm) {
|
||||||
mcopy.arduino.serial[device].on('data', data => {
|
mcopy.arduino.serial[device].on('data', data => {
|
||||||
let d = data.toString('utf8')
|
let d = data.toString('utf8')
|
||||||
|
d = d.replace(newlineRe, '').replace(returnRe, '')
|
||||||
d = d.replace(newlineRe, '')
|
|
||||||
mcopy.arduino.end(d)
|
mcopy.arduino.end(d)
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
mcopy.arduino.serial[device].on('data', data => {
|
mcopy.arduino.serial[device].on('data', data => {
|
||||||
let d = data.toString('utf8')
|
let d = data.toString('utf8')
|
||||||
d = d.replace(newlineRe, '')
|
d = d.replace(newlineRe, '').replace(returnRe, '')
|
||||||
mcopy.arduino.confirmEnd(d)
|
mcopy.arduino.confirmEnd(d)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ mcopy.arduino.connect = function (serial, device, confirm, callback) {
|
||||||
|
|
||||||
mcopy.arduino.confirmExec = {};
|
mcopy.arduino.confirmExec = {};
|
||||||
mcopy.arduino.confirmEnd = function (data) {
|
mcopy.arduino.confirmEnd = function (data) {
|
||||||
|
//console.dir(data)
|
||||||
if (data === mcopy.cfg.arduino.cmd.connect
|
if (data === mcopy.cfg.arduino.cmd.connect
|
||||||
|| data === mcopy.cfg.arduino.cmd.proj_identifier
|
|| data === mcopy.cfg.arduino.cmd.proj_identifier
|
||||||
|| data === mcopy.cfg.arduino.cmd.cam_identifier
|
|| data === mcopy.cfg.arduino.cmd.cam_identifier
|
||||||
|
|
Loading…
Reference in New Issue