Skip to content

Commit

Permalink
fixed #53 - devices command did not require a valid connection
Browse files Browse the repository at this point in the history
  • Loading branch information
AndiDittrich committed Jul 22, 2018
1 parent 001b6fd commit b6c488a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
8 changes: 7 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
5 changes: 1 addition & 4 deletions lib/cli/nodemcu-tool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
13 changes: 10 additions & 3 deletions lib/connector/list-devices.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit b6c488a

Please sign in to comment.