Skip to content

Commit

Permalink
fix bug concerning empty ports being polled for pnpId's
Browse files Browse the repository at this point in the history
  • Loading branch information
noopkat committed Oct 3, 2015
1 parent d29135e commit 95bd963
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions avrgirl-arduino.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,13 +328,20 @@ Avrgirl_arduino.prototype._sniffPort = function (callback) {
for (var i = 0; i < ports.length; i++) {
// iterate through all possible pid's
for (var j = 0; j < self.board.productId.length; j ++) {
var pid;
// are we on windows or unix?
var pid = ports[i].productId ? ports[i].productId : '0x' + /PID_\d*/.exec(ports[i].pnpId)[0].substr(4);
if (ports[i].productId) {
pid = ports[i].productId;
} else if (ports[i].pnpId) {
pid = '0x' + /PID_\d*/.exec(ports[i].pnpId)[0].substr(4);
} else {
pid = '';
}
if (pid === self.board.productId[j]) {
// match! Return the port/path
return callback(ports[i].comName);
}
}
}
}
// didn't find a match :(
return callback(null);
Expand Down

0 comments on commit 95bd963

Please sign in to comment.