Hi, I am attempting to expand the functionality of the node-red-serial-port node by allowing it to take in the PID, VID and serial number of a serial device and connect to the the corresponding serial port, as opposed to just entering the desired serial port.
To do this, I need to retrieve the list of serial devices connected to the device currently. To my knowledge this is done like this:
var ports_list = [];
await SerialPort.list().then(function(ports){
ports.forEach(function(port){
ports_list.push(port);
})
});
I have tested this in a function node and it appeared to work correctly. However, when I attempted to implement it into the node-red file I got this error:
15 Jul 08:55:30 - [info] Waiting for missing types to be registered:
15 Jul 08:55:30 - [info] - serial-port (provided by npm module node-red-node-serialport)
15 Jul 08:55:30 - [info] - serial in (provided by npm module node-red-node-serialport)
15 Jul 08:55:30 - [info] To install any of these missing modules, run:
15 Jul 08:55:30 - [info] npm install <module name>
15 Jul 08:55:30 - [info] in the directory:
Although I am sure that the nodes are present as I do not get this error when I remove the added code.
I believe that it is an issue with the await function, as I do not get this error if I remove the await, however the list of serial devices cannot be collected.
Is there something I am missing in regards to using asynchronous functions in node-red?
Thanks