Skip to content

Commit ef6fd1e

Browse files
committed
Auto Start Monitor, Exclude Debug Serial from Autoconnect
1 parent 1646596 commit ef6fd1e

3 files changed

Lines changed: 33 additions & 6 deletions

File tree

SerialUI.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def __init__(self, parent=None, logger=None):
569569
# end/RX wiring follows transport readiness
570570
# ----------------------------------------
571571

572-
self.txrxReady_wired_to_ble = False
572+
self.txrxReady_wired_to_ble = False
573573
self.txrxReady_wired_to_serial = False
574574

575575
# combined throughput stats
@@ -961,7 +961,10 @@ def showEvent(self, event):
961961
if USE_FASTPLOTLIB:
962962
QTimer.singleShot(200, self.chart.fpl_figure_init)
963963
else:
964-
QTimer.singleShot(200, self.chart.pg_figure_init)
964+
QTimer.singleShot(200, self.chart.pg_figure_init)
965+
966+
# Start the Monitoring by default
967+
QTimer.singleShot(0, lambda: self.runMonitoringRequest.emit(True))
965968

966969
@pyqtSlot()
967970
def closeEvent(self, event):

config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from helpers.colors import color_names_sweet16 as COLORS
77
################################################################################################################################
88
# Constants General
9-
VERSION = "1.4.0" # this version
9+
VERSION = "1.4.1" # this version
1010
AUTHOR = "Urs Utzinger" # me
1111
DATE = "2025" # year of last update
1212
################################################################################################################################

helpers/Qserial_helper.py

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,17 @@ def on_usb_event_detected(self, message: str) -> None:
459459
port_names.append(info.description())
460460
port_hwids.append(f"{info.vendorIdentifier():04X}:{info.productIdentifier():04X}")
461461

462+
# Helper: exclude “debug” interfaces from auto-connect offers
463+
# ESP port name changes and contains "debug" when uploading firmware
464+
# After programming it reverts to normal port name without "debug"
465+
def is_debug_port(name: str, desc: str) -> bool:
466+
try:
467+
name_l = (name or "").lower()
468+
desc_l = (desc or "").lower()
469+
return ("debug" in name_l) or ("debug" in desc_l)
470+
except Exception:
471+
return False
472+
462473
if "USB device removed" in message:
463474
# Check if the device is still there
464475
if self.serialPort not in ports and self.serialPort != "":
@@ -492,6 +503,13 @@ def on_usb_event_detected(self, message: str) -> None:
492503
if best_score > 0.8:
493504
# find the port that matches the previous hwid
494505
indx = port_hwids.index(best_match)
506+
# Skip debug-class interfaces (don’t auto-reconnect to them)
507+
if is_debug_port(ports[indx], port_names[indx]):
508+
self.awaitingReconnection = False
509+
self.logSignal.emit(logging.INFO,
510+
f"[{self.instance_name[:15]:<15}]: Skipping auto‑reconnect to debug interface: {ports[indx]} ({port_names[indx]})."
511+
)
512+
return
495513
self.serialPort_backup = ports[indx]
496514
self.serialPort_previous = ports[indx]
497515
QTimer.singleShot( 0, lambda: self.scanPortsRequest.emit()) # request new port list, takes 225ms to complete
@@ -513,10 +531,16 @@ def on_usb_event_detected(self, message: str) -> None:
513531
else:
514532
# We have new device insertion, connect to it
515533
if self.serialPort == "":
516-
# new_ports = [port for port in ports if port not in self.serialPorts] # prevents device to be opened that was previously found but not opened
517-
new_ports = [port for port in ports]
518-
new_portnames = [port_names[ports.index(port)] for port in new_ports if port in ports] # Get corresponding names
534+
# Build candidate list excluding debug-class interfaces
535+
candidates = [(p, n) for p, n in zip(ports, port_names) if not is_debug_port(p, n)]
536+
new_ports = [p for (p, _) in candidates]
537+
new_portnames = [n for (_, n) in candidates]
519538

539+
if not new_ports:
540+
self.logSignal.emit(logging.INFO,
541+
f"[{self.instance_name[:15]:<15}]: No eligible (non‑debug) USB serial device to offer for auto‑connect."
542+
)
543+
return
520544
# Figure out if useable port
521545
if new_ports:
522546
new_port = new_ports[0] # Consider first found new port

0 commit comments

Comments
 (0)