summaryrefslogtreecommitdiff
path: root/devices/arduino_device.py
diff options
context:
space:
mode:
authorChristian Kolset <ckolset@colostate.edu>2026-08-13 11:09:03 -0600
committerChristian Kolset <ckolset@colostate.edu>2026-08-13 11:09:03 -0600
commit4d08be2656d5599caf60ab5163a9d2305b397daf (patch)
treed78e764e21995b47eca79d184460f14eb52cdd22 /devices/arduino_device.py
parent012a1093e3cb9a1b376fc3beee4df859ccfb8da5 (diff)
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 <noreply@anthropic.com>
Diffstat (limited to 'devices/arduino_device.py')
-rw-r--r--devices/arduino_device.py8
1 files changed, 7 insertions, 1 deletions
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)