Skip to content

Fix WebUSB serial #55

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

Merged
merged 5 commits into from
Apr 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/usb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,12 @@ class MicrobitWebUSBConnectionImpl
protected eventActivated(type: string): void {
switch (type as keyof SerialConnectionEventMap) {
case "serialdata": {
this.startSerialInternal();
// Prevent starting serial when flashing.
if (!this.flashing) {
this.startSerialInternal();
}
Comment on lines +486 to +489
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This prevents serial from starting when flashing is in progress in the Python Editor. Adding event listener in device hook in the python editor causes serial to get started in the flashing process.

// Allows for reinstating serial after flashing.
this.addedListeners.serialdata++;
break;
}
}
Expand All @@ -493,6 +498,7 @@ class MicrobitWebUSBConnectionImpl
switch (type as keyof SerialConnectionEventMap) {
case "serialdata": {
this.stopSerialInternal();
this.addedListeners.serialdata--;
break;
}
}
Expand Down