Skip to content

Commit

Permalink
update node 10 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Böber committed Jul 27, 2019
1 parent bb89e03 commit 259ceeb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"MySensors"
],
"dependencies": {
"serialport": "~2.0.6"
"serialport": "~6.2.1"
},
"peerDependencies": {
"pimatic": ">=0.8.0 <1.0.0"
Expand Down
10 changes: 6 additions & 4 deletions serialport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module.exports = (env) ->
events = require 'events'

serialport = require("serialport")
SerialPort = serialport.SerialPort
SerialPort = require 'serialport'
Readline = require('@serialport/parser-readline')

Promise = env.require 'bluebird'
Promise.promisifyAll(SerialPort.prototype)
Expand All @@ -15,8 +16,8 @@ module.exports = (env) ->
env.logger.debug "initializing SerialPortDriver"
@serialPort = new SerialPort(protocolOptions.serialDevice, {
baudRate: protocolOptions.baudrate,
parser: serialport.parsers.readline("\n")
}, openImmediately = no)
autoOpen: false
})

connect: (timeout, retries) ->
# cleanup
Expand All @@ -32,7 +33,8 @@ module.exports = (env) ->
#resolver = null

# setup data listener
@serialPort.on("data", (data) =>
@parser = @serialPort.pipe(new Readline("\n"));
@parser.on("data", (data) =>
# Sanitize data
line = data.replace(/\0/g, '').trim()
@emit('data', data)
Expand Down

0 comments on commit 259ceeb

Please sign in to comment.