From 0bef6680280e4489bb9608f89f844e8b31ec13f9 Mon Sep 17 00:00:00 2001 From: Dave Conway-Jones Date: Wed, 13 Nov 2019 18:43:43 +0000 Subject: [PATCH] fix button class and serial.list promise --- io/serialport/25-serial.html | 7 ++----- io/serialport/25-serial.js | 12 +++++++++--- io/serialport/package.json | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/io/serialport/25-serial.html b/io/serialport/25-serial.html index f0e461ff..1ecc910c 100644 --- a/io/serialport/25-serial.html +++ b/io/serialport/25-serial.html @@ -147,7 +147,7 @@
- +
@@ -354,10 +354,7 @@ $("#node-config-lookup-serial").addClass('disabled'); $.getJSON('serialports',function(data) { $("#node-config-lookup-serial").removeClass('disabled'); - var ports = []; - $.each(data, function(i, port) { - ports.push(port.comName); - }); + var ports = data || []; $("#node-config-input-serialport").autocomplete({ source:ports, minLength:0, diff --git a/io/serialport/25-serial.js b/io/serialport/25-serial.js index 7218e8b7..6fdd34a8 100644 --- a/io/serialport/25-serial.js +++ b/io/serialport/25-serial.js @@ -444,8 +444,14 @@ module.exports = function(RED) { }()); RED.httpAdmin.get("/serialports", RED.auth.needsPermission('serial.read'), function(req,res) { - serialp.list(function (err, ports) { - res.json(ports); - }); + serialp.list().then( + ports => { + const a = ports.map(p => p.path); + res.json(a); + }, + err => { + node.log('Error listing serial ports', err) + } + ) }); } diff --git a/io/serialport/package.json b/io/serialport/package.json index 0d21c890..c365d785 100644 --- a/io/serialport/package.json +++ b/io/serialport/package.json @@ -1,6 +1,6 @@ { "name" : "node-red-node-serialport", - "version" : "0.9.0", + "version" : "0.9.1", "description" : "Node-RED nodes to talk to serial ports", "dependencies" : { "serialport" : "^8.0.5"