@@ -329,8 +329,14 @@ def poll_pyudev(self, poll_ms: int) -> None:
329329
330330 def poll_ports (self , poll_ms : int ) -> None :
331331 """
332- Basic polling fallback when pyudev is not available (Darwin or minimal Linux).
333- Emits added/removed events by diffing serial ports.
332+ Basic serial-port polling fallback used when native USB notifications are
333+ unavailable or unreliable.
334+
335+ Used on Darwin and minimal Linux when pyudev is not available, and on
336+ Windows when WMI event subscriptions are not available in the current
337+ environment.
338+
339+ Emits added/removed events by diffing the available serial ports.
334340 """
335341 self .logSignal .emit (logging .INFO ,
336342 f"[{ self .instance_name [:15 ]:<15} ]: Monitoring USB with serial port polling fallback and interval { poll_ms / 1000 } s"
@@ -345,7 +351,8 @@ def poll_ports(self, poll_ms: int) -> None:
345351 try :
346352 def current_set ():
347353 ports = _QSPI .availablePorts ()
348- # Prefer absolute system path if available (Linux/Mac), else synthesize from portName
354+ # Prefer absolute system path if available (Linux/macOS), else
355+ # fall back to the reported port name such as COMx on Windows.
349356 items = []
350357 for p in ports :
351358 try :
@@ -401,11 +408,11 @@ def monitor_usb_windows(self) -> None:
401408 try :
402409 import wmi
403410 except Exception as e :
404- self .logSignal .emit (logging .ERROR ,
405- f"[{ self .instance_name [:15 ]:<15} ]: wmi module not available: { e } "
411+ self .logSignal .emit (logging .WARNING ,
412+ f"[{ self .instance_name [:15 ]:<15} ]: wmi module not available: { e } ; falling back to serial port polling. "
406413 )
407- self .finished . emit ( )
408- return
414+ self .poll_ports ( poll_ms )
415+ return
409416 c = wmi .WMI ()
410417
411418 try :
@@ -414,9 +421,10 @@ def monitor_usb_windows(self) -> None:
414421 "remove" : c .Win32_PnPEntity .watch_for (notification_type = "Deletion" , delay_secs = 0.2 )
415422 }
416423 except Exception as e :
417- self .logSignal .emit (logging .ERROR ,
418- f"[{ self .instance_name [:15 ]:<15} ]: Error setting up USB monitor: { e } "
424+ self .logSignal .emit (logging .WARNING ,
425+ f"[{ self .instance_name [:15 ]:<15} ]: Error setting up USB monitor: { e } ; falling back to serial port polling. "
419426 )
427+ self .poll_ports (poll_ms )
420428 return
421429
422430 while self .running :
0 commit comments