summaryrefslogtreecommitdiff
path: root/api_layers/protocols/mark10.py
diff options
context:
space:
mode:
Diffstat (limited to 'api_layers/protocols/mark10.py')
-rw-r--r--api_layers/protocols/mark10.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/api_layers/protocols/mark10.py b/api_layers/protocols/mark10.py
index 4a97892..b7dacb4 100644
--- a/api_layers/protocols/mark10.py
+++ b/api_layers/protocols/mark10.py
@@ -43,8 +43,9 @@ class Mark10Layer(BaseProtocol):
def _poll(self) -> Dict[str, float]:
try:
- self._ser.write(b"?\r")
- resp = self._ser.readline().decode(errors="replace").strip()
+ with self._io_lock:
+ self._ser.write(b"?\r")
+ resp = self._ser.readline().decode(errors="replace").strip()
return self._parse(resp)
except Exception:
return {}
@@ -83,7 +84,8 @@ class Mark10Layer(BaseProtocol):
if not self._ser:
return False
try:
- self._ser.write(cmd)
+ with self._io_lock:
+ self._ser.write(cmd)
return True
except Exception:
return False
@@ -92,8 +94,10 @@ class Mark10Layer(BaseProtocol):
def zero(self) -> None:
if self._ser:
- self._ser.write(b"Z\r")
+ with self._io_lock:
+ self._ser.write(b"Z\r")
def cycle_units(self) -> None:
if self._ser:
- self._ser.write(b"U\r")
+ with self._io_lock:
+ self._ser.write(b"U\r")