Linux USB unplugged hangs app, no error #115

Closed
nottledim opened this Issue Dec 12, 2012 · 4 comments

Comments

Projects
None yet
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

This comment has been minimized.

Show comment Hide comment
@franxois

franxois Dec 11, 2013

Same here

Raspberry with picore 4.7.7
node 0.10.7
serialport 1.2.5

Same here

Raspberry with picore 4.7.7
node 0.10.7
serialport 1.2.5

@reconbot

This comment has been minimized.

Show comment Hide comment
@reconbot

reconbot Dec 11, 2013

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.

Collaborator

reconbot commented Dec 11, 2013

@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

This comment has been minimized.

Show comment Hide comment
@franxois

franxois Feb 24, 2014

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 ...");
    });
});

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

This comment has been minimized.

Show comment Hide comment
@voodootikigod

voodootikigod Sep 22, 2014

Collaborator

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

Collaborator

voodootikigod commented Sep 22, 2014

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