-
Notifications
You must be signed in to change notification settings - Fork 37
WebUSB: On serial connection check baud rate before setting it. #1103
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
WebUSB: On serial connection check baud rate before setting it. #1103
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Tested with v1, v2.00, and v2.21, and the program no longer resets on switching tabs. Some minor changes requested via comments.
Awesome, thanks @microbit-robert! |
Ah, there are merge conflicts and it needs to be rebased anyway, I'll do that. |
Setting the baud rate makes DAPLink send a "break signal", which resets the target. This is triggered when switching tabs as it resets the user's micro:bits when the editor goes out of focus and active again.. We can avoid this reset by checking first the DAPLink serial settings and only set the baud rate if necessary.
Okay, should be ready for merge now 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
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).