From 4d08be2656d5599caf60ab5163a9d2305b397daf Mon Sep 17 00:00:00 2001 From: Christian Kolset Date: Thu, 13 Aug 2026 11:09:03 -0600 Subject: Re-detect serial device ports by identity when a profile loads on another machine COM/tty numbers aren't stable across machines or replugs. Devices now save their USB serial number and OS description alongside the port; on profile load, if the saved port isn't present, ArduinoLayer.find_port_by_identity() looks for a match and remaps it. Falls back to the saved port (device shows ERROR) if nothing matches. Co-Authored-By: Claude Sonnet 5 --- devices/arduino_device.py | 8 +++++++- devices/serial_device.py | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'devices') diff --git a/devices/arduino_device.py b/devices/arduino_device.py index 3ad0c7b..1641eaa 100644 --- a/devices/arduino_device.py +++ b/devices/arduino_device.py @@ -206,7 +206,7 @@ class ArduinoDevice(BaseDevice): return False def get_save_config(self) -> dict: - return { + cfg = { "device_type": self.DEVICE_TYPE, "device_id": self.info.device_id, "name": self.info.name, @@ -217,6 +217,12 @@ class ArduinoDevice(BaseDevice): "port": self._port, "baud": self._baud, } + if not self.simulate: + # Saved so a profile loaded on another machine (different COM/tty + # numbering) can still find this device — see ProfileManager.apply(). + cfg["port_desc"] = ArduinoLayer.describe_port(self._port) + cfg["port_serial"] = ArduinoLayer.port_serial_number(self._port) + return cfg def get_config_widget(self) -> QWidget: return ArduinoConfigWidget(self) diff --git a/devices/serial_device.py b/devices/serial_device.py index cef34e8..d402f09 100644 --- a/devices/serial_device.py +++ b/devices/serial_device.py @@ -210,6 +210,11 @@ class SerialDevice(BaseDevice): "parse_format": self._fmt, "simulate": self.simulate, } + if not self.simulate: + # Saved so a profile loaded on another machine (different COM/tty + # numbering) can still find this device — see ProfileManager.apply(). + cfg["port_desc"] = ArduinoLayer.describe_port(self._port) + cfg["port_serial"] = ArduinoLayer.port_serial_number(self._port) if self._fmt in _GENERIC_FORMATS: cfg.update({ "num_channels": len(self.info.channels), -- cgit v1.2.3