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

Fix timeout handling serial write #652

Merged
merged 2 commits into from
Feb 26, 2021
Merged

Conversation

dNechita
Copy link
Contributor

No description provided.

A timeout happens when the number of written bytes is less than the requested number of bytes to be written.

Signed-off-by: Dan Nechita <[email protected]>
All other error messages have this, except the ones that are now being fixes with this commit.

Signed-off-by: Dan Nechita <[email protected]>
@dNechita dNechita requested review from rgetz and mhennerich February 22, 2021 12:12
@rgetz
Copy link
Contributor

rgetz commented Feb 22, 2021

Don't we need to handle the error? Just printing something, and allowing a partial write to occur will confuse the system.,,

@dNechita
Copy link
Contributor Author

dNechita commented Feb 22, 2021

Don't we need to handle the error? Just printing something, and allowing a partial write to occur will confuse the system.,,

When the timeout occurs, yes we print something but then we immediately return and provide the error code for the timeout.
Did you have something else in mind about what needs to be done to handle the timeout?

@rgetz
Copy link
Contributor

rgetz commented Feb 23, 2021

just returning in the middle - will leave the client/server in an unknown state (although that looks like what usb does); so maybe it is OK.

when I test this, I get different results based on the random devices:

rgetz@brain:~/github/libiio-master/build$ time ./tests/iio_info -u serial:/dev/ttyUSB0
Library version: 0.21 (git tag: 9d79757)
Compiled with backends: local xml ip usb serial
ERROR: sp_blocking_read_next has timedoutERROR: READ LINE: -110
Unable to create IIO context serial:/dev/ttyUSB0: Connection timed out (110)

real	0m31.020s
user	0m0.114s
sys	0m0.114s

31 seconds it pretty long to time out?

rgetz@brain:~/github/libiio-master/build$ time ./tests/iio_info -u serial:/dev/ttyACM0
Library version: 0.21 (git tag: 9d79757)
Compiled with backends: local xml ip usb serial
ERROR: sp_blocking_read_next has timedoutERROR: READ LINE: -110
Unable to create IIO context serial:/dev/ttyACM0: Connection timed out (110)

real	0m1.038s
user	0m0.009s
sys	0m0.000s

seems more reasonable.

@rgetz
Copy link
Contributor

rgetz commented Feb 25, 2021

I dug into this a little bit... This seems to be an issue in the FTDI kernel driver.

https://stackoverflow.com/questions/14255314/close-function-on-serial-port-descriptor-blocks-in-linux

there is no way to set the closing_wait function that I can find on this driver, it's set to 30 seconds...

only suggestion was to have the close will probably need to be called in a separate thread... (which I'm not sure is worth the problem?) If we want to make serial scan work - it will be necessary....

@dNechita
Copy link
Contributor Author

Thanks for investigating things. I'm going to merge this. Also I've created an issue to track the 30 seconds timeout issue.

@dNechita dNechita merged commit 89e337b into master Feb 26, 2021
@dNechita dNechita deleted the fix-timeout-handling-serial-write branch February 26, 2021 09:34
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

Successfully merging this pull request may close these issues.

2 participants