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

Incorrect timeout duration with readline #291

Open
nicolas-cadart opened this issue Sep 14, 2023 · 0 comments
Open

Incorrect timeout duration with readline #291

nicolas-cadart opened this issue Sep 14, 2023 · 0 comments

Comments

@nicolas-cadart
Copy link

Thanks for this great library!

I was running some tests and found out that the timeout feature does not work as expected when using the readline (and probably readlines too) method. After digging a bit into the code, I found that readline(256) runs 256 times a read(1) call. Therefore, the timeout is reset for each individual byte, and does not account for the whole 256 bytes reading.

I noticed this issue when running some tests using an incorrect baudrate (9600 instead of the correct 115200), with a simple global timeout of 3000 ms. The readline(256) call terminates after several tens of seconds (value not stable across different repetitions), while the read(256) call correctly terminates after max 3 s (it might return earlier, but returning noise because of wrong baudrate). In my situation, I don't know the baudrate being used, so I need to automatically check if the received data looks correct to validate a baudrate before using it.

My machine is running on Ubuntu 20.04.

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

No branches or pull requests

1 participant