-
Notifications
You must be signed in to change notification settings - Fork 126
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
read
is always non-blocking even when no data is available to read
#12
Comments
Possibly related to #25 I guess that the current solution for 'wait forever' on read would be: port.set_timeout(Duration::MAX).ok(); |
At least in posix systems, it is because of this: #[cfg(target_os = "linux")]
let wait_res = {
let timespec = TimeSpec::milliseconds(milliseconds);
nix::poll::ppoll(slice::from_mut(&mut fd), Some(timespec), SigSet::empty())
};
#[cfg(not(target_os = "linux"))]
let wait_res = nix::poll::poll(slice::from_mut(&mut fd), milliseconds as nix::libc::c_int);
In the case of linux systems, the |
@eranknafo2001 Agreed, but I don't think there is any way to express 'no timeout' in serialport-rs (see my comment here) -- so we're left with 'wait for a really long time' as a work-around. |
I created a PR to fix it #50 |
Termios is a layer on top of a raw serial port. I think serial port library should just stick to simple support for serial port, and we can write extensions on top. But we shouldn't complicate serial-port-rs. |
This issue was migrated from GitLab. The original issue can be found here:
https://gitlab.com/susurrus/serialport-rs/-/issues/89
The current behavior of
read
on an open serial port is that it always returns immediately, even when there is no data available in the input buffer. This may be in contradiction with the understanding here (from tty.rs).It's also not consistent and not obvious how to make it consistent with the description from https://linux.die.net/man/3/cfmakeraw related to canonical/non-canonical modes. Please note that according to that explanation, raw mode does not guarantee that reads blocks if no data is available. Non-canonical mode with MIN > 0; TIME == 0 or MIN == 0; TIME > 0 or MIN > 0; TIME > 0.
Please clarify what is the intention of serialport-rs implementation, and how to make read block when no data is available for a configurable maximum timeout.
The text was updated successfully, but these errors were encountered: