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

Serial port disconnect throws a non-catchable fatal error #3

Closed
sylvinus opened this issue Mar 7, 2011 · 4 comments
Closed

Serial port disconnect throws a non-catchable fatal error #3

sylvinus opened this issue Mar 7, 2011 · 4 comments

Comments

@sylvinus
Copy link

sylvinus commented Mar 7, 2011

... or I don't know how to catch it.

How to reproduce : plug an arduino in at /dev/ttyACM1 , begin reading data, disconnect the arduino.

I get :

Error: ENODEV, No such device
at
var bytes_read = serialport_native.read(file_id,buffer);

@sylvinus
Copy link
Author

sylvinus commented Mar 8, 2011

also, having a "close" event, I tried to do it like this but didn't quite work :

var readWatcher = new IOWatcher();
this.empty_reads = 0;

var fd = this.fd;
readWatcher.callback = (function (file_id, me) {
  return function () {
    var buffer = new Buffer(255);

    try {
      var bytes_read = serialport_native.read(file_id, buffer);
    } catch (e) {

      me.emit('close', file_id);
      readWatcher.stop();
      serialport_native.close(fd);
      return;
    }

    me.emit('data', buffer.slice(0, bytes_read));
  }
})(this.fd, this);
readWatcher.set(this.fd, true, false);
readWatcher.start();

@voodootikigod
Copy link
Collaborator

Can you verify that it still occurs now with 0.2.1 version? I do not have an arduino board but in my tests it handles this cleanly now.

@sylvinus
Copy link
Author

sylvinus commented Mar 8, 2011

thanks for the reactivity on all the issues :) I'll test that asap.

@voodootikigod
Copy link
Collaborator

Closing unless further details

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants