TinyCircuits / TinyCircuits-Thumby-Code-Editor

https://code.thumby.us/
GNU General Public License v3.0
30 stars 20 forks source link

Keyboard interrupt in Fast Execute fix #32

Closed fuglaro closed 2 years ago

fuglaro commented 2 years ago

This would show in the IDE Console like this:

MicroPython v1.19.1 on 2022-06-18; Raspberry Pi Pico with RP2040 Type "help()" for more information.

Traceback (most recent call last): File "", line 1, in File "/lib/thumbyGrayscale.py", line 13, in KeyboardInterrupt:


This was due to the IDE not recognising the OK response when it was interleaved with previous message that were never captured, e.g:

raw REPL; CTRL-B to exit

OK

This change handles response messages more predictably, avoiding messages mixing together, and also gives Fast Execute a little bit longer before bailing.

This approach also solves the rarer issue where the Filesystem panel never fills after the Thumby is connected. The underlying issue was how haltUntilRead would accept an omitOffset argument that would consume additional lines after the expected line, and that calling functions, like softReset, would expect haltUntilRead to consume those lines. Unfortunately, haltUntilRead would only consume additional lines that had already been received by the time the expected line was encountered. If there was a delay with the additional lines, they would not be consumed. This was a problem for softReset, which would not always consume the raw mode prompt: raw REPL; CTRL-B to exit

which would end up arriving while waitUntilOK was waiting for the OK message, often messing up the detection. This solution makes haltUntilRead wait until the additional offset lines arrive, and time out if they don't arrive soon after. This would of caused the softReset function to always pause, because it was waiting on an additional line that would never arrive. Since softReset is only used in raw mode, this has also been tuned to the correct number of expected lines. In practice, even with this reduction of the number of omit offset lines, it most likely consumes more lines than it used to, because the additional lines were subject to a delay that will only now be waited on.

ghost commented 2 years ago

Looks good to me! Merged. I'll update the site but without a version change.