From 3e7bf3e1bd65a1108fc6a2c318207d8e185c8d33 Mon Sep 17 00:00:00 2001 From: neoqix Date: Fri, 6 Nov 2026 22:12:31 +0100 Subject: [PATCH 1/3] Fix opz_os_read.py getting stuck while reading On my machine, the script got stuck reading os.ldr around 802k. This fixed it and Pyserial recommends to manage read buffers this way. --- tools/opz_os_read.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/opz_os_read.py b/tools/opz_os_read.py index dad62a4..867ce72 100755 --- a/tools/opz_os_read.py +++ b/tools/opz_os_read.py @@ -169,7 +169,7 @@ def collect(self, want_type, first_timeout, idle_timeout, progress=False): logs, start = [], time.monotonic() last, started, pend = start, False, None while True: - chunk = self.port.read(65536) + chunk = self.port.read(self.port.in_waiting) now = time.monotonic() if chunk: last = now From 7e5b7bc0827c528e5b1c065455ef52929d8ce628 Mon Sep 17 00:00:00 2001 From: neoqix Date: Fri, 6 Nov 2026 22:31:18 +0100 Subject: [PATCH 2/3] Fix missing in_waiting for opz_os_read unit test --- tools/tests/test_opz_os_read.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/tests/test_opz_os_read.py b/tools/tests/test_opz_os_read.py index edb0ba7..f0f8c23 100644 --- a/tools/tests/test_opz_os_read.py +++ b/tools/tests/test_opz_os_read.py @@ -84,6 +84,13 @@ def write(self, frame): def flush(self): pass + @property + def in_waiting(self): + k = min(self.chunk, len(self.queue)) + if self.stall_after is not None: + k = min(k, max(0, self.stall_after - self.sent)) + return k + def read(self, n): if self.stall_after is not None and self.sent >= self.stall_after: self.clock.t += 0.5 From 6a148a8ede96ade959137c6dd15915ff11551036 Mon Sep 17 00:00:00 2001 From: neoqix Date: Fri, 6 Nov 2026 22:36:20 +0100 Subject: [PATCH 3/3] Correctly handle empty serial buffer in opz_os_read --- tools/opz_os_read.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/opz_os_read.py b/tools/opz_os_read.py index 867ce72..6d953e2 100755 --- a/tools/opz_os_read.py +++ b/tools/opz_os_read.py @@ -169,7 +169,7 @@ def collect(self, want_type, first_timeout, idle_timeout, progress=False): logs, start = [], time.monotonic() last, started, pend = start, False, None while True: - chunk = self.port.read(self.port.in_waiting) + chunk = self.port.read(self.port.in_waiting or 1) now = time.monotonic() if chunk: last = now