Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.

Commit

Permalink
fix mixup in error handling when opening a serialport connection
Browse files Browse the repository at this point in the history
  • Loading branch information
jamuus committed Oct 19, 2015
1 parent 05e267a commit 886c148
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/adaptors/serialport.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 5 additions & 1 deletion lib/sphero.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 886c148

Please sign in to comment.