From b6c488ab68d8410e8c97c3a5eee4bce7edc3853d Mon Sep 17 00:00:00 2001 From: Andi Dittrich Date: Sun, 22 Jul 2018 18:10:21 +0200 Subject: [PATCH] fixed #53 - devices command did not require a valid connection --- CHANGES.md | 8 +++++++- lib/cli/nodemcu-tool.js | 5 +---- lib/connector/list-devices.js | 13 ++++++++++--- package.json | 2 +- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cbf9482..12e17aa 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,8 +1,14 @@ ## --- Branch 3.x --- ## -### 3.0.0 ### Refactored the codebase - make extensive use of ES6 feature like async/await + +### 3.0.1 ### + +* Bugfix: command `devices` failed in case a nonexisting serial port was used (e.g. default port; command did not require a valid port) - thanks to [arrowcircle on GitHub](https://github.com/AndiDittrich/NodeMCU-Tool/issues/53) #53 + +### 3.0.0 ### + * Added: flag `--run` to **upload** command to run a file on NodeMCU diretly after uploading - feature [requested on GitHub](https://github.com/AndiDittrich/NodeMCU-Tool/issues/19) #19 * Added: return codes (0-success; 1-general_error; 127-lowlevel_error) - feature [requested on GitHub](https://github.com/AndiDittrich/NodeMCU-Tool/issues/48) #48 * Added: **debug mode** to show low-level error messages `--debug` flag diff --git a/lib/cli/nodemcu-tool.js b/lib/cli/nodemcu-tool.js index f5bbd3a..ee96465 100755 --- a/lib/cli/nodemcu-tool.js +++ b/lib/cli/nodemcu-tool.js @@ -319,12 +319,9 @@ async function terminal(initialCommand=null){ // show serial devices connected to the system async function devices(showAll, jsonOutput){ - - // try to establish a connection to the module - await getConnection(); try{ - const serialDevices = await _nodeMcuConnector.listDevices(); + const serialDevices = await _nodeMcuConnector.listDevices(showAll); if (jsonOutput){ writeOutput(JSON.stringify(devices)); diff --git a/lib/connector/list-devices.js b/lib/connector/list-devices.js index 3999659..3e9ed86 100755 --- a/lib/connector/list-devices.js +++ b/lib/connector/list-devices.js @@ -1,5 +1,14 @@ const _serialport = require('../transport/serialport'); +// list of known vendor IDs +const knownVendorIDs = [ + // NodeMCU v1.0 - CH341 Adapter | 0x1a86 QinHeng Electronics + '1a86', + + // NodeMCU v1.1 - CP2102 Adapter | 0x10c4 Cygnal Integrated Products, Inc + '10c4' +]; + // show connected serial devices async function listDevices(showAll){ // get all available serial ports @@ -10,11 +19,9 @@ async function listDevices(showAll){ return ports; // filter by vendorIDs - // NodeMCU v1.0 - CH341 Adapter | 0x1a86 QinHeng Electronics - // NodeMCU v1.1 - CP2102 Adapter | 0x10c4 Cygnal Integrated Products, Inc }else{ return ports.filter(function(item){ - return (item.vendorId == '1a86' || item.vendorId == '10c4'); + return knownVendorIDs.includes(item.vendorId); }); } } diff --git a/package.json b/package.json index 1a486e5..e9ad55f 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nodemcu-tool", - "version": "3.0.0", + "version": "3.0.1", "description": "Command line tool to upload and manage files on your NodeMCU / ESP8266 Module / ESP32 Module.", "keywords": [ "cli",