-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
rp2/machine_uart.c: Change wait in uart.flush() and uart.read(). #13379
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
Conversation
Thanks for the patch. Now I think about it, maybe also the UART interrupts are enabled for both RX and TX, but they are FIFO interrupts and so an IRQ won't necessarily fire, eg, if you're waiting for exactly 1 incoming byte. For writing in |
Would be good if we can write a test for this failure, eg write some bytes out on the UART and time how long the flush takes. |
Thanks for the comments. I will do both, changing uart.read and write a test case. |
c16ec84
to
609d760
Compare
Updated with a test and change for uart.read(). |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #13379 +/- ##
=======================================
Coverage 98.36% 98.36%
=======================================
Files 159 159
Lines 21088 21088
=======================================
Hits 20743 20743
Misses 345 345 ☔ View full report in Codecov by Sentry. |
Good catch, thanks @robert-hh. Forgot that you don't always get an interrupt in these cases due to the FIFOs. |
Do not wait in the worst case up to the timeout. Fixes issue micropython#13377. Signed-off-by: robert-hh <[email protected]>
I've updated the test so it tests multiple baud rates, and so it's possible to run on other ports/boards. |
Currently only runs on rp2 but could be extended to run on other targets. Signed-off-by: robert-hh <[email protected]>
In case someone else encounters this weird bug - this commit appears to have fixed an issue I had with the Pi Pico UART always reading an extra byte when It wasn't waiting for any stop bits - so if the line rose and stayed high, this would be incorrectly interpreted as a null byte (a real null byte should have a stop bit - a negative-going pulse at the appropriate time). This was an issue for me because an RS485 transciever would set the line high when it stopped recieving, so every byte recieved would be followed by an extra null byte. Anyway moving from v1.21.0 to v1.22.1 has resolved this issue for me, and this PR is the most likely candidate as to why, so thank you! |
Do not wait in the worst case up to the next ms tick.
Fixes Issue #13377