Skip to content

Commit 7ee3783

Browse files
fix: Allow for reinstating serial after flashing
1 parent a28d04b commit 7ee3783

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

lib/usb.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,11 @@ class MicrobitWebUSBConnectionImpl
313313
this.visibilityReconnect = true;
314314
} else {
315315
if (this.addedListeners.serialdata) {
316-
this.log("Reinstating serial after flash");
317-
if (this.connection.daplink) {
318-
await this.connection.daplink.connect();
319-
await this.startSerialInternal();
316+
this.log("Reinstating serial after flash");
317+
if (this.connection.daplink) {
318+
await this.connection.daplink.connect();
319+
await this.startSerialInternal();
320+
}
320321
}
321322
}
322323
}
@@ -482,10 +483,12 @@ class MicrobitWebUSBConnectionImpl
482483
protected eventActivated(type: string): void {
483484
switch (type as keyof SerialConnectionEventMap) {
484485
case "serialdata": {
486+
// Prevent starting serial when flashing.
485487
if (!this.flashing) {
486488
this.startSerialInternal();
487-
this.addedListeners.serialdata = 1;
488489
}
490+
// Allows for reinstating serial after flashing.
491+
this.addedListeners.serialdata = 1;
489492
break;
490493
}
491494
}

0 commit comments

Comments
 (0)