From 559a1bfe97d8a7c1ddbd97cd39bfe275f58e9e44 Mon Sep 17 00:00:00 2001 From: Ian Newton Date: Fri, 7 Mar 2025 17:04:20 +0000 Subject: [PATCH] Make usb sensor timeout more robust --- validitysensor/usb.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/validitysensor/usb.py b/validitysensor/usb.py index ae67576..7382509 100644 --- a/validitysensor/usb.py +++ b/validitysensor/usb.py @@ -122,10 +122,13 @@ def cancel(self): def wait_int(self): self.cancel = False + max_retries = 3 # Number of retry attempts before giving up + retry_count = 0 + timeout_ms = 500 # Increased timeout from 100ms to 500ms while True: try: - resp = self.dev.read(131, 1024, timeout=100) + resp = self.dev.read(131, 1024, timeout=timeout_ms) resp = bytes(resp) self.trace('