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

open () returning while fd is null #507

Closed
lcrocker opened this issue Apr 13, 2015 · 2 comments
Closed

open () returning while fd is null #507

lcrocker opened this issue Apr 13, 2015 · 2 comments

Comments

@lcrocker
Copy link

Using 1.6.3 on Linux (Ubuntu 14.04). Doing the usual:

p = serialport.SerialPort('/dev/ttyUSB0', { ... });
p.on('open', function () {
    some_callback();
});

In my callback, the port object is all there, but the "fd" property of the port object is still null, and attempting a write() will throw an exception. Simply waiting until fd is not null fixes the issue, but really, shouldn't open() be doing that, and not returning until the port is actually open and ready for business?

@lcrocker
Copy link
Author

Found this on several versions, and it seems to be related to running under a shell. When the program is run by manually typing "nodejs ./myprog.js ...", then all is well, or if it is run from .bashrc. It's when I try to run the program from a Gnome autostart script that it fails. "fd" comes out 0. Maybe it's legitimately returning fd 0 in this case, and we can't deal with it. In this state, all writes fail and this condition persists, so I can't just wait it out.

@reconbot
Copy link
Member

@lcrocker the port should be open and writes shouldn't fail after an open event. We didn't support systems where the fd might be 0, but now we do! Our latest beta 2.0.7-beta2 lands support you can read more #688

Please try it out and let us know if this fixes your issue!

@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

No branches or pull requests

2 participants