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

TTYPort::read doesn't respect timeout #7

Open
jessebraham opened this issue Feb 7, 2022 · 0 comments · May be fixed by #192
Open

TTYPort::read doesn't respect timeout #7

jessebraham opened this issue Feb 7, 2022 · 0 comments · May be fixed by #192
Labels
migrated This issue was migrated from GitLab posix This issue is specific to posix systems

Comments

@jessebraham
Copy link
Member

This issue was migrated from GitLab. The original issue can be found here:
https://gitlab.com/susurrus/serialport-rs/-/issues/74

I have an application that sometimes just hangs, seemingly forever. I've tracked the problem down to TTYPort::read.

I'm setting a timeout on the port and I know this works, as the application experiences timeouts quite regularly. Despite this, the call to read doesn't return. I've added some debug output, and tracked the problem to the second call in read. super::poll::wait_read_fd returns, nix::unistd::read doesn't.

The serial port I'm using is connected through USB to a microcontroller, and something really weird is going on over there (longstanding USB-related bug that I wasn't able to track down so far). I'm not surprised that this is causing weird behavior on the host side. However, it would be great, if serialport-rs could respect the timeout setting under such circumstances, if at all possible.

@jessebraham jessebraham added the migrated This issue was migrated from GitLab label Feb 7, 2022
@jessebraham jessebraham added the posix This issue is specific to posix systems label Mar 7, 2022
danielstuart14 added a commit to danielstuart14/serialport-rs that referenced this issue May 24, 2024
In some cases, when a underlying error happens to a TTY port between poll::wait_read_fd and unistd::read, the read function would hang waiting for some data that is never received.

This commit sets the port to non-canonical mode, with VMIN = VTIME = 0. With this change, it has the effect of making reads non-blocking, returning right away.

The timeout behaviour is maintained, as prior to reading we call unix::poll through poll::wait_read_fd.

Fixes: serialport#7
danielstuart14 added a commit to danielstuart14/serialport-rs that referenced this issue May 24, 2024
In some cases, when a underlying error happens to a TTY port between poll::wait_read_fd and unistd::read, the read function would hang waiting for some data that is never received.

This commit sets the port to non-canonical mode, with VMIN = VTIME = 0. With this change, it has the effect of making reads non-blocking, returning right away.

The timeout behaviour is maintained, as prior to reading we call unix::poll through poll::wait_read_fd.

Fixes: serialport#7
danielstuart14 added a commit to danielstuart14/serialport-rs that referenced this issue May 24, 2024
In some cases, when a underlying error happens to a TTY port between poll::wait_read_fd and unistd::read, the read function would hang waiting for some data that is never received.

This commit sets the port to non-canonical mode, with VMIN = VTIME = 0. With this change, it has the effect of making reads non-blocking, returning right away.

The timeout behaviour is maintained, as prior to reading we call unix::poll through poll::wait_read_fd.

Fixes: serialport#7
@danielstuart14 danielstuart14 linked a pull request May 24, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
migrated This issue was migrated from GitLab posix This issue is specific to posix systems
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant