From 41b4a3dccc8a39c50b6ae6166e79d304ef2ea1bb Mon Sep 17 00:00:00 2001 From: Christopher Pietsch Date: Sun, 15 Dec 2019 15:25:15 +0100 Subject: [PATCH 1/2] added vendorId for windows (0D28) --- client/MBFirmataClient.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/MBFirmataClient.js b/client/MBFirmataClient.js index 8c20668..424da7f 100644 --- a/client/MBFirmataClient.js +++ b/client/MBFirmataClient.js @@ -116,7 +116,7 @@ class MicrobitFirmataClient { .then((ports) => { for (var i = 0; i < ports.length; i++) { var p = ports[i]; - if ((p.vendorId == '0d28') && (p.productId == '0204')) { + if ((p.vendorId == "0d28" || p.vendorId == "0D28") && (p.productId == '0204')) { return p.comName; } } From dc234b1b15648d99516eaa1bb0077685e90dd4d5 Mon Sep 17 00:00:00 2001 From: Christopher Pietsch Date: Sun, 15 Dec 2019 15:27:41 +0100 Subject: [PATCH 2/2] added promise return to connect() --- client/MBFirmataClient.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/MBFirmataClient.js b/client/MBFirmataClient.js index 424da7f..39094f1 100644 --- a/client/MBFirmataClient.js +++ b/client/MBFirmataClient.js @@ -112,7 +112,7 @@ class MicrobitFirmataClient { connect() { // Search serial port list for a connected micro:bit and, if found, open that port. - serialport.list() + return serialport.list() .then((ports) => { for (var i = 0; i < ports.length; i++) { var p = ports[i]; @@ -127,10 +127,11 @@ class MicrobitFirmataClient { // Attempt to open the serial port on the given port name. // If this fails it will fail with an UnhandledPromiseRejectionWarning. console.log("Opening", portName); - this.setSerialPort(new serialport(portName, { baudRate: 57600 })); + return this.setSerialPort(new serialport(portName, { baudRate: 57600 })); } else { console.log("No micro:bit found; is your board plugged in?"); } + return null }); } @@ -151,7 +152,7 @@ class MicrobitFirmataClient { // get the board serial number (used to determine board version) this.boardVersion = ''; - serialport.list() + return serialport.list() .then((ports) => { for (var i = 0; i < ports.length; i++) { var p = ports[i]; @@ -159,7 +160,7 @@ class MicrobitFirmataClient { this.boardVersion = this.boardVersionFromSerialNumber(p.serialNumber); } } - return null; + return this; }) }