Skip to content

Commit

Permalink
node-arduino-firmata: test for SerialPort 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nxhack committed Aug 24, 2018
1 parent 8e01006 commit 54632ac
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions node-arduino-firmata/patches/900-fix_the_usage_of_serialport.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
diff --git a/src/arduino-firmata.coffee b/src/arduino-firmata.coffee
index fa6abb7..aa86664 100644
--- a/src/arduino-firmata.coffee
+++ b/src/arduino-firmata.coffee
@@ -1,7 +1,7 @@
'use strict'

events = require 'eventemitter2'
-{SerialPort} = serialport = require 'serialport'
+serialport = require 'serialport'

debug = require('debug')('arduino-firmata')

@@ -42,6 +42,7 @@ exports = module.exports = class ArduinoFirmata extends events.EventEmitter2
callback null, devices

constructor: ->
+ super()
@status = ArduinoFirmata.Status.CLOSE
@wait_for_data = 0
@execute_multi_byte_command = 0
@@ -57,7 +58,7 @@ exports = module.exports = class ArduinoFirmata extends events.EventEmitter2
isOldArduinoDevice: ->
return /usbserial|USB/.test @serialport_name

- connect: (@serialport_name, opts={baudrate: 57600}) ->
+ connect: (@serialport_name, opts={baudRate: 57600}) ->
opts.parser = serialport.parsers.raw
unless @serialport_name
ArduinoFirmata.list (err, devices) =>
@@ -82,7 +83,7 @@ exports = module.exports = class ArduinoFirmata extends events.EventEmitter2
@emit 'connect'
, io_init_wait

- @serialport = new SerialPort @serialport_name, opts
+ @serialport = new serialport @serialport_name, opts
@serialport.once 'open', =>
cid = setInterval =>
debug 'request REPORT_VERSION'
diff --git a/tests/test_arduino.coffee b/tests/test_arduino.coffee
index 3009336..776c2a4 100644
--- a/tests/test_arduino.coffee
+++ b/tests/test_arduino.coffee
@@ -16,10 +16,9 @@ describe 'class ArduinoFirmata', ->

describe 'method list', ->

- it 'should return list of serialports', (done) ->
+ it 'should return list of serialports', ->
ArduinoFirmata.list (err, devices) ->
- assert.equal devices instanceof Array, true
- done()
+ assert.equal (devices instanceof Array), true


describe 'instance of ArduinoFirmata', ->

0 comments on commit 54632ac

Please sign in to comment.