Skip to content

Commit

Permalink
add port sniffing fallback for linux/win leo reset port hopping risks
Browse files Browse the repository at this point in the history
  • Loading branch information
noopkat committed Dec 8, 2015
1 parent 96b1c93 commit e2ece7f
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,21 @@ Connection.prototype._pollForPort = function(callback) {
if (tries < 4) {
setTimeout(checkList, delay);
} else {
// timeout on too many tries
return callback(new Error('could not reconnect after resetting board.'));
// try to sniff port instead (for port hopping devices) {
_this._sniffPort(function(error, port) {
if (port.length) {
// found a port, save it
_this.options.port = port[0].comName;

// set up serialport for it
_this._setUpSerial(function(error) {
return callback(error);
});
} else {
// timeout on too many tries
return callback(new Error('could not reconnect after resetting board.'));
}
});
}
});
}
Expand Down

0 comments on commit e2ece7f

Please sign in to comment.