8000 tools/pyboard.py: Prevent non-blocking serial reads. by jaenrig-ifx · Pull Request #10000 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

tools/pyboard.py: Prevent non-blocking serial reads. #10000

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

Closed

Conversation

jaenrig-ifx
Copy link
Contributor

Added timeout to avoid blocking call to read()
preventing the test runner to wait forever
for incoming data from a irresponsive target.

Signed-off-by: jaenrig-ifx enriquezgarcia.external@infineon.com

< 8000 /include-fragment>
Added timeout to avoid blocking call to read()
preventing the test runner to wait forever
for incoming data from a irresponsive target.

Signed-off-by: jaenrig-ifx <enriquezgarcia.external@infineon.com>
@jaenrig-ifx jaenrig-ifx force-pushed the pyboard-non-blocking-read-fix branch from 295909f to 2384148 Compare November 17, 2022 17:31
@dpgeorge dpgeorge added the tools Relates to tools/ directory in source, or other tooling label Nov 18, 2022
@dpgeorge
Copy link
Member

Thanks for the contribution.

We need to be careful with low-level changes to pyboard.py because it underpins a lot of other tools, like mpremote.

This change makes it so that read_until() does not necessarily read min_num_bytes of data from the serial port (this will happen if there is a timeout in that first call to read in that function).

I'm not sure if that actually creates a problem, but it seems like this change is making things more complicated and error prone.

Looking at callers of read_until, they all pass 1 as the min_num_bytes argument. So maybe we can remove that argument and rework the function to work without it, and with a timeout set on the serial object. That's a bit of work and outside the scope of this PR though.

@jaenrig-ifx
Copy link
Contributor Author

Hi @dpgeorge,

Understood. I wasn´t aware that this was used outside the testing suite.
Besides read_until() I see there are other 7 calls to serial.read(). These could potentially accept higher waiting times. If a non-blocking serial.read() is implemented, all the processes calling it should consider the case where no or insufficient data is received, and act upon.
It does not seem to be a option to set a timeout for each serial.read() call, but for the whole Serial instance. That would be ideal, as it could only apply to the call in read_until().

7CE7
@jaenrig-ifx jaenrig-ifx deleted the pyboard-non-blocking-read-fix branch April 26, 2023 11:02
tannewt pushed a commit to tannewt/circuitpython that referenced this pull request Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tools Relates to tools/ directory in source, or other tooling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0