Repository navigation
Conversation
Fixes issue micropython#7731. Signed-off-by: Damien George <[email protected]>
Codecov Report
@@ Coverage Diff @@
## master #8265 +/- ##
=======================================
Coverage 98.47% 98.47%
=======================================
Files 153 153
Lines 20145 20145
=======================================
Hits 19838 19838
Misses 307 307 Continue to review full report at Codecov.
|
| else: | ||
| if len(data_all) == 0: | ||
| if t - t_start > INITIAL_TIMEOUT: | ||
| return |
There was a problem hiding this comment.
So does this mean that every time the board is in raw mode, or any other "special" mode where no immediate response is expected, ctrl-d will essentially introduce a 0.5s delay?
Actually I guess Raw mode is exited by ctrl-d so would normally return something, such as a prompt, so should be the 0.2s timeout.
Not saying that's necessarily a problem... Just wanting to check I'm following this right.
There was a problem hiding this comment.
You are right. But it's no worse than the previous behaviour which was:
- if nothing mounted, return immediately (that's still the behaviour here)
- if something mounted then wait 0.5 seconds for at least one char
- if any chars received within that 0.5 seconds then assume the ctrl-D that was sent triggered a soft reset, and then wait for all chars to be received before remounting
So the improvements here are:
- don't ever wait longer than 5 seconds (FULL_TIMEOUT)
- always check for "MPY: soft reboot" and a valid prompt indicator (eg ">>> ") to indicate a soft reset was done
| break | ||
| time.sleep(0.05) | ||
| # Check if a soft reset occurred. | ||
| if data_all.find(b"MPY: soft reboot") == -1: |
There was a problem hiding this comment.
Pyserial has some functions that could make this simpler, eg
read_until() reads input while watching for a desired pattern or timeout (
https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.read_until)
Or even just using its built in timeouts rather than manually managing it here?
It's got separate settings for overall read operation timeout (https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.timeout) and inter byte timeouts (https://pyserial.readthedocs.io/en/latest/pyserial_api.html#serial.Serial.inter_byte_timeout)
Edit:
Ah, I see there's a custom pyboard.read_until that could possibly be used, but doesn't have as fine grain timeout second. Also, the compatibility layer with telnet doesn't have the extra timeout settings, that's one reason to not use the pyserial ones.
I also haven't looked at the code in the pyserial timeouts, don't know if it's actually more efficient at all.
There was a problem hiding this comment.
We don't want to exit early if the desired pattern is found, because we still need to read and process all incoming chars until it's "quiet", to know it's ready for the remount command.
And I don't think the pyserial timeout settings are enough for the case of 3 different timeout values used here (initial wait, inter-char waits, total timeout).
|
Merged in fecfd52 |
…n-main Translations update from Hosted Weblate
Changes:
Fixes issue #7731.