summaryrefslogtreecommitdiff
path: root/api_layers/protocols/mark10.py
diff options
context:
space:
mode:
authorChristian Kolset <ckolset@colostate.edu>2026-07-28 17:01:38 -0600
committerChristian Kolset <ckolset@colostate.edu>2026-07-28 17:01:38 -0600
commitb2dc94bb2e7c7e57cba202697ed4d58bbb1f01f5 (patch)
tree3c495f951024f3a69113137bc065769e4428a513 /api_layers/protocols/mark10.py
parent96ef35db552d26e6d962c9ff6f9da5c928c0ad76 (diff)
Update CML protocol documentation and improve command handling; adjust motion_capture setting to false
Diffstat (limited to 'api_layers/protocols/mark10.py')
-rw-r--r--api_layers/protocols/mark10.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/api_layers/protocols/mark10.py b/api_layers/protocols/mark10.py
index b7dacb4..a209232 100644
--- a/api_layers/protocols/mark10.py
+++ b/api_layers/protocols/mark10.py
@@ -10,6 +10,11 @@ Commands (sent with CR terminator):
Response format: "+0.1234 kgF" (sign, value, space, unit suffix)
+Replies are read up to CR with Serial.read_until(b"\\r") rather than
+readline(), since pyserial's readline() looks for LF by default and the
+gauge only terminates with CR — readline() would otherwise block for the
+full serial timeout on every poll.
+
Channels exposed:
force — current force reading (in instrument's selected unit)
unit_code — numeric index into UNITS list (lb=0, kgF=1, N=2, ozF=3)
@@ -44,8 +49,10 @@ class Mark10Layer(BaseProtocol):
def _poll(self) -> Dict[str, float]:
try:
with self._io_lock:
+ self._ser.reset_input_buffer()
self._ser.write(b"?\r")
- resp = self._ser.readline().decode(errors="replace").strip()
+ self._ser.flush()
+ resp = self._ser.read_until(b"\r").decode(errors="replace").strip()
return self._parse(resp)
except Exception:
return {}