Skip to content

Commit a9ade06

Browse files
Try to add polling for disconnects
1 parent ccb4d29 commit a9ade06

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

kernel/src/services/DeviceService.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ export class DeviceService {
88
private deviceType: string = '';
99
private decoder: TextDecoder = new TextDecoder();
1010

11-
constructor() {}
11+
constructor() {
12+
// Contiuously check the port status every 2 seconds to update the connection status/card
13+
setInterval(() => {
14+
if (this.port && !this.port.readable && !this.port.writable) {
15+
console.log('[DeviceService]: Port is not readable or writable, disconnecting...');
16+
this.disconnect();
17+
}
18+
}, 2000);
19+
20+
}
1221

1322
// Check if port is available (return true if available)
1423
// Don't run if we are already connected from within this tab

0 commit comments

Comments
 (0)