Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Linux USB unplugged hangs app, no error #115

Closed
nottledim opened this Issue · 4 comments

4 participants

@nottledim

Similar to issue #95 but on Linux

Reading from /dev/ttyUSB0 serial device. Unplug USB device and app hangs (event loop blocked I assume). No errors reported or emitted.

@franxois

Same here

Raspberry with picore 4.7.7
node 0.10.7
serialport 1.2.5

@reconbot
Collaborator

@JayBeavers I have no way of testing most of this currently as it should be occurring from within the serialport-bindings.

I can make sure the disconnect callback gets passed to the binding, but that's about it.

@franxois

Hi,

I tried to debug by doing some modification to the _serialportReadable(uv_poll_t *req, int status, int events) function in the serial_poller.cpp file.

I add

printf("status :%d %d\n", status, events); 

at the line 24.

The output change from
status :0 1
to
status :-1 0
when I unplug the serial device

I avoid the infinite loop by adding a test on status before calling the obj->callCallback()

if (status > -1) {
        obj->callCallback();
    }

I would like to emit a "close" event at this point. Is it possible and how ?

My node code is

var serialport = require("node-serialport");
var sys = require('sys');

var SerialPort = serialport.SerialPort; // localize object constructor

var sp = new SerialPort("/dev/ttyUSB0", {
    baudrate : 9600,
    parser : serialport.parsers.readline("\n"),
});

var i = 1;

serialport.list(function (err, ports) {
    console.log( ports );
    });

sp.on("open", function() {
    console.log('open');
    sp.on('data', function(data) {
        sys.debug('count : ' + (i++));
        console.log('data received: ' + data);
    });

    sp.on('error', function(err) {
        console.log("Error ?? " + err);
    });

    sp.on('close', function() {
        console.log("We closed the port ...");
    });
});
@voodootikigod

Closing due to age, if still issue, please resubmit ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.