fix: try both COM11 and \\.\COM11 formats when opening serial port

pyserial should auto-add \\.\ prefix for COM>=10, but some versions
don't. Added _open_serial() helper that tries the raw port name first,
then falls back to explicit NT namespace prefix on Windows.

Replaces all serial.Serial() calls across serial_monitor, reboot_manager,
and widgets.
This commit is contained in:
2026-06-12 09:46:31 +08:00
parent 4ef1ce0c6b
commit 36fbb6a662
3 changed files with 37 additions and 7 deletions
+2 -1
View File
@@ -1077,7 +1077,8 @@ class UartMonitorWindow(ctk.CTkToplevel):
def _bg_open() -> None:
try:
import serial
ser = serial.Serial(self._port, self._baudrate, timeout=1)
from serial_monitor import _open_serial
ser = _open_serial(self._port, self._baudrate, 1)
ser.close()
self.after(0, self._on_open_success)
except Exception as e: