You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var SERIALPORT = require("serialport");
var serialPort = SERIALPORT.SerialPort;
var listAndConnect = function ()
{
SERIALPORT.list(function (err, ports) {
ports.forEach(function (port) {
console.log("opening " + port.comName);
var sp = new serialPort(port.comName, {
parser: SERIALPORT.parsers.raw
});
sp.on("data", function (data) {
console.log(port.comName + ": " + data);
});
sp.on('disconnect', function (err) {
console.log('on.disconnect');
setTimeout(listAndConnect, 2000);
});
sp.on("close", function () {
console.log("on.close");
});
sp.on("error", function (err) {
console.log("on.error");
console.log(err);
});
});
});
};
listAndConnect();
The script list COM port, connect to them and echo the data on input. When it receive the disconnect event, it wait 2 seconds before listing and connecting again.
On windows :
node 0.10.32, latest nodeserial. I use usb FTDI device or usb arduino.
As expected, when I unplug the usb device, the program goes to the disconnect event.
On linux :
i5 with Ubuntu 14.04 64bit, last node
Raspberry Pi, raspbian & node 0.10.28
When I unplug, the message "on.disconnect" never appears. node hangs, the CPU goes to 100%.
The text was updated successfully, but these errors were encountered:
Hello,
Here is the code I test on windows
The script list COM port, connect to them and echo the data on input. When it receive the disconnect event, it wait 2 seconds before listing and connecting again.
node 0.10.32, latest nodeserial. I use usb FTDI device or usb arduino.
As expected, when I unplug the usb device, the program goes to the disconnect event.
i5 with Ubuntu 14.04 64bit, last node
Raspberry Pi, raspbian & node 0.10.28
When I unplug, the message "on.disconnect" never appears. node hangs, the CPU goes to 100%.
The text was updated successfully, but these errors were encountered: