File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -15,19 +15,19 @@ export class DeviceService {
15
15
this . port = port ;
16
16
17
17
// Check if the port is open by another application (or ourselves in another tab)
18
- if ( this . port . readable && this . port . writable ) {
19
- console . log ( 'Port is already open, skipping request' ) ;
18
+
19
+ // Perform a quick open and close of port to check if it's already open
20
+ if ( this . port . readable || this . port . writable ) {
21
+ console . log ( '[requestPort]: Port is already open, skipping request' ) ;
20
22
return ;
21
23
}
22
24
else {
23
- console . log ( 'Port is not open, requesting transport for port' ) ;
25
+ console . log ( '[requestPort]: Port is not open, requesting port' ) ;
24
26
}
25
-
26
27
this . transport = new Transport ( port ) ;
27
28
28
-
29
29
} catch ( err ) {
30
- console . error ( 'Failed to get port:' , err ) ;
30
+ console . error ( '[requestPort]: Failed to get port:' , err ) ;
31
31
throw err ;
32
32
}
33
33
}
You can’t perform that action at this time.
0 commit comments