Skip to content

Commit 4f77bcf

Browse files
Fix WebUSB serial (#55)
Reinstate serial after flashing to fix starting of serial after flashing (main issue and related issue 1) Don't start serial when flashing to fix flashing issues (related issue 2) Fixes microbit-foundation/python-editor-v3#1209
1 parent e1fe420 commit 4f77bcf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/usb.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,12 @@ class MicrobitWebUSBConnectionImpl
483483
protected eventActivated(type: string): void {
484484
switch (type as keyof SerialConnectionEventMap) {
485485
case "serialdata": {
486-
this.startSerialInternal();
486+
// Prevent starting serial when flashing.
487+
if (!this.flashing) {
488+
this.startSerialInternal();
489+
}
490+
// Allows for reinstating serial after flashing.
491+
this.addedListeners.serialdata++;
487492
break;
488493
}
489494
}
@@ -493,6 +498,7 @@ class MicrobitWebUSBConnectionImpl
493498
switch (type as keyof SerialConnectionEventMap) {
494499
case "serialdata": {
495500
this.stopSerialInternal();
501+
this.addedListeners.serialdata--;
496502
break;
497503
}
498504
}

0 commit comments

Comments
 (0)