Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not receiving "disconnect" event on Linux #386

Closed
franxois opened this issue Sep 23, 2014 · 0 comments · Fixed by #393
Closed

Not receiving "disconnect" event on Linux #386

franxois opened this issue Sep 23, 2014 · 0 comments · Fixed by #393

Comments

@franxois
Copy link

Hello,

Here is the code I test on windows

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%.
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging a pull request may close this issue.

1 participant