summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--api_layers/protocols/mark10.py5
-rw-r--r--devices/serial_device.py8
2 files changed, 13 insertions, 0 deletions
diff --git a/api_layers/protocols/mark10.py b/api_layers/protocols/mark10.py
index a209232..48ed927 100644
--- a/api_layers/protocols/mark10.py
+++ b/api_layers/protocols/mark10.py
@@ -44,6 +44,11 @@ class Mark10Layer(BaseProtocol):
super().__init__(port, baud, poll_interval, simulate)
self._unit = "N"
+ @property
+ def current_unit(self) -> str:
+ """Last unit suffix seen in a gauge reply (e.g. "N", "kgF")."""
+ return self._unit
+
# ── Protocol ──────────────────────────────────────────────────────────
def _poll(self) -> Dict[str, float]:
diff --git a/devices/serial_device.py b/devices/serial_device.py
index 067656a..eadaa42 100644
--- a/devices/serial_device.py
+++ b/devices/serial_device.py
@@ -142,6 +142,14 @@ class SerialDevice(BaseDevice):
raw = self._layer.read()
if not raw:
return {}
+ if self._fmt == "mark10" and hasattr(self._layer, "current_unit"):
+ # Gauge can be switched between lb/kgF/N/ozF on the device itself —
+ # keep the channel's unit in sync so new plots/pickers/CSV log
+ # headers pick up the currently-selected unit instead of a fixed
+ # default. Does not relabel the axis of an already-open plot pane.
+ force_ch = self.get_channel("force")
+ if force_ch is not None:
+ force_ch.unit = self._layer.current_unit
if self._fmt not in _GENERIC_FORMATS:
# Protocol layers already key by channel_id — pass through untouched.
# (Write-only channels, e.g. CML "M1_VS", never appear in raw — correctly dropped.)