diff --git a/lib/adaptors/serialport.js b/lib/adaptors/serialport.js index afe3813..afc42b8 100644 --- a/lib/adaptors/serialport.js +++ b/lib/adaptors/serialport.js @@ -50,13 +50,13 @@ util.inherits(Adaptor, EventEmitter); */ Adaptor.prototype.open = function open(callback) { var self = this, - port = this.serialport = new serialport.SerialPort(this.conn, {}); + port = this.serialport = new serialport.SerialPort(this.conn, {}, false); function emit(name) { return self.emit.bind(self, name); } - port.on("open", function(error) { + port.open(function(error) { if (error) { callback(error); return; diff --git a/lib/sphero.js b/lib/sphero.js index d92e20c..7f5686c 100644 --- a/lib/sphero.js +++ b/lib/sphero.js @@ -89,7 +89,11 @@ Sphero.prototype.connect = function(callback) { connection.on("open", emit("open")); - connection.open(function() { + connection.open(function(error) { + if (error) { + callback(error); + return; + } self.ready = true; connection.onRead(function(payload) {