Skip to content

Commit

Permalink
Mac fix for serialport detection match
Browse files Browse the repository at this point in the history
  • Loading branch information
techninja committed May 22, 2018
1 parent 163de95 commit ad1b50d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/cncserver.serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ module.exports = function(cncserver){
*/
cncserver.serial.autoDetectPort = function (botControllerConf, callback) {
var botMaker = botControllerConf.manufacturer.toLowerCase();
var botProductId = botControllerConf.productId.toLowerCase();
var botProductId = parseInt(botControllerConf.productId.toLowerCase());
var botName = botControllerConf.name.toLowerCase();

// Output data arrays.
Expand All @@ -118,7 +118,10 @@ module.exports = function(cncserver){

ports.forEach(function(port){
var portMaker = (port.manufacturer || "").toLowerCase();
var portProductId = (port.productId || "").toLowerCase();
// Convert reported product ID from hex string to decimal.
var portProductId = parseInt(
'0x' + (port.productId || "").toLowerCase()
);
var portPnpId = (port.pnpId || "").toLowerCase();

// Add this port to the clean list if its vendor ID isn't undefined.
Expand All @@ -137,9 +140,10 @@ module.exports = function(cncserver){

break;
default: // includes 'darwin', 'linux'
// Match by contains productID/pnpID and exact Manufacturer.
// Match by Exact Manufacturer...
if (portMaker === botMaker) {
if (portProductId.indexOf(botProductId) !== -1 ||
// Match by exact product ID (hex to dec), or PNP ID partial
if (portProductId === botProductId ||
portPnpId.indexOf(botName) !== -1) {
detectList.push(port.comName);
}
Expand Down

0 comments on commit ad1b50d

Please sign in to comment.