Skip to content

Commit a28d04b

Browse files
fix: update addedListeners when serial data is added
1 parent 83533b8 commit a28d04b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

lib/usb.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,7 @@ class MicrobitWebUSBConnectionImpl
312312
await this.disconnect();
313313
this.visibilityReconnect = true;
314314
} else {
315+
if (this.addedListeners.serialdata) {
315316
this.log("Reinstating serial after flash");
316317
if (this.connection.daplink) {
317318
await this.connection.daplink.connect();
@@ -483,6 +484,7 @@ class MicrobitWebUSBConnectionImpl
483484
case "serialdata": {
484485
if (!this.flashing) {
485486
this.startSerialInternal();
487+
this.addedListeners.serialdata = 1;
486488
}
487489
break;
488490
}
@@ -493,6 +495,7 @@ class MicrobitWebUSBConnectionImpl
493495
switch (type as keyof SerialConnectionEventMap) {
494496
case "serialdata": {
495497
this.stopSerialInternal();
498+
this.addedListeners.serialdata = 0;
496499
break;
497500
}
498501
}

0 commit comments

Comments
 (0)