From d6e2ca8d1a146eab95741c0800f874c9d71da048 Mon Sep 17 00:00:00 2001 From: x12sa Date: Fri, 11 Sep 2026 09:11:08 +0200 Subject: [PATCH] fix(omny): mitigate scrambled Galil PUT/GET communication with settle delays GalilController had zero delay in its socket path (write immediately followed by a blocking read), unlike sgalil_ophyd.py's GalilController which already sleeps 10ms in both socket_put and socket_get. This increased the chance of partial-packet collisions/desync between commands and responses during flomni beamtime (see command_history showing merged/missing PUT-GET pairs). Add a 10ms sleep to socket_put and a socket_get override (also with a 10ms sleep) that logs into command_history, mirroring the existing sgalil_ophyd.py pattern. This reduces desync likelihood but does not fully fix it: failed socket_get attempts are still swallowed silently by retry_once with no trace in command_history, and receive() still does a single recv(1024) with no terminator framing. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01XdHenMmwbrCz1juWMi1yZc --- csaxs_bec/devices/omny/galil/galil_ophyd.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/csaxs_bec/devices/omny/galil/galil_ophyd.py b/csaxs_bec/devices/omny/galil/galil_ophyd.py index de0ce5ff..ea1ddc7a 100644 --- a/csaxs_bec/devices/omny/galil/galil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/galil_ophyd.py @@ -58,9 +58,17 @@ class GalilController(Controller): @threadlocked def socket_put(self, val: str) -> None: + time.sleep(0.01) self.command_history.append(f"[PUT]: {val}") self.sock.put(f"{val}\r".encode()) + @threadlocked + def socket_get(self) -> str: + time.sleep(0.01) + response = self.sock.receive().decode() + self.command_history.append(f"[GET]: {response}") + return response + @retry_once def socket_put_confirmed(self, val: str) -> None: """Send message to controller and ensure that it is received by checking that the socket receives a colon.