From 7e359cd8382f7276bae350ba32e734e19dbd01a5 Mon Sep 17 00:00:00 2001 From: Rick Wierenga Date: Mon, 2 Feb 2026 19:12:32 -0800 Subject: [PATCH 1/2] return empty on hid success error --- pylabrobot/io/hid.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pylabrobot/io/hid.py b/pylabrobot/io/hid.py index 012c23ee11b..ce4345f4b93 100644 --- a/pylabrobot/io/hid.py +++ b/pylabrobot/io/hid.py @@ -3,6 +3,8 @@ from concurrent.futures import ThreadPoolExecutor from typing import Optional, cast +from hid import HIDException + from pylabrobot.io.capture import CaptureReader, Command, capturer, get_capture_or_validation_active from pylabrobot.io.errors import ValidationError from pylabrobot.io.io import IOBase @@ -156,7 +158,12 @@ async def read(self, size: int, timeout: int) -> bytes: def _read(): assert self.device is not None, "forgot to call setup?" - return self.device.read(size, timeout=int(timeout)) + try: + return self.device.read(size, timeout=int(timeout)) + except HIDException as e: + if str(e) == "Success": + return b"" + raise if self._executor is None: raise RuntimeError("Call setup() first.") From 0dce436667d4f6293b148dcadc9d56d8af10c948 Mon Sep 17 00:00:00 2001 From: Rick Wierenga Date: Mon, 2 Feb 2026 19:14:31 -0800 Subject: [PATCH 2/2] type --- pylabrobot/io/hid.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pylabrobot/io/hid.py b/pylabrobot/io/hid.py index ce4345f4b93..f4b15434266 100644 --- a/pylabrobot/io/hid.py +++ b/pylabrobot/io/hid.py @@ -3,8 +3,6 @@ from concurrent.futures import ThreadPoolExecutor from typing import Optional, cast -from hid import HIDException - from pylabrobot.io.capture import CaptureReader, Command, capturer, get_capture_or_validation_active from pylabrobot.io.errors import ValidationError from pylabrobot.io.io import IOBase @@ -12,6 +10,7 @@ try: import hid # type: ignore + from hid import HIDException USE_HID = True except ImportError as e: