Closed microbit-carlos closed 1 year ago
Awesome, thanks @microbit-robert! I've left the GitHub web interface commits assuming this PR will be squashed when merged, but let me know if you prefer the branch to be squashed beforehand instead.
Ah, there are merge conflicts and it needs to be rebased anyway, I'll do that.
Okay, should be ready for merge now 👍
Now we've done this it might be worth trying to avoid resetting the serial console (i.e clearing scrollback) in this scenario as that's what most folks have been complaining about. Needs some thought though as serial output that doesn't match the running program is confusing (e.g. we might show a clickable traceback for it).
Setting the baud rate makes DAPLink send a "break signal", which basically resets the target.
This is noticeable to the Python Editor users when switching tabs as it makes their programme reset.
We can avoid this reset by checking first the DAPLink serial settings and only set the baud rate if necessary.
For devices with DAPLink 0257 and newer (V2.2) the default baud rate is set to 115200 already, so they will never reset on WebUSB connection. For devices with older DAPLink versions (V1 and V2.00) the editor will set the baud rate on first connection (triggering a reset), but won't have to set it again until the device is unplugged.
I tried to replicate the
Bad response for 8 -> 17
issue for about 5 minutes changing tabs and refreshing-and-reconnecting and it seems fine (and also checked that it's really easy to replicate in the Python Editor v2).