-
Notifications
You must be signed in to change notification settings - Fork 109
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
When call(UART, read, 2000)
times out, subsequent reads will always be {error, ealready}
#1446
Comments
I found the root cause of this error. If no data is immediately available to return; a callback handler will send the data, after it arrives, to the pid (stored as the current listener) which requested it with the last Your timeout is not being passed to the driver as a timer to invalidate the listener. This has not been implemented yet, so you are just aborting the receive... which at this point some data must be lost when it is received by the callback, which will send the data to the pid that made the first A temporary workaround for your application would be to drop into a receive without a timeout when it gets an |
Thanks for looking at it @UncleGrumpy. I think your temporary workaround is hard to work for me because I will be doing many writes with corresponding reads, many of which could be invalid writes that nothing can be read from. My workaround that I've implemented is to close the UART port after a timeout. HOWEVER, a close crashes the program. BUT @pguyot on Discord has kindly made a fix here pguyot@af80836 (which I'd like to know if it's merged in yet) with associated image at https://github.com/pguyot/AtomVM/actions/runs/12587958508 which closes without a crash provided there is a wait time before you open a new UART port again. |
That fix was merged into the release-0.6 branch so that the bug fix will be included in the next update. At some point soon (if not already) it will also be merged into main as part of the future 0.7 releases. |
port:call(UART, read, 2000)
finishes timing out, then a subsequent valid write expecting a response will result with a read that always return a{error, ealready}
.Example:
Output:
The text was updated successfully, but these errors were encountered: