From 2762fe680a03706d3c21efe51db9b1f8d193d2d0 Mon Sep 17 00:00:00 2001 From: Angus Gratton Date: Wed, 5 Nov 2025 15:41:35 +1100 Subject: [PATCH] tests/serial_test.py: Allow up to 2 seconds between bytes. Only a problem when UART TX is also enabled and goes first (i.e. esp32 port) as sending 16384 bytes in one go triggers the timeout. This work was funded through GitHub Sponsors. Signed-off-by: Angus Gratton --- tests/serial_test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/serial_test.py b/tests/serial_test.py index 1baa2282a0..455d2277f6 100755 --- a/tests/serial_test.py +++ b/tests/serial_test.py @@ -103,6 +103,11 @@ def read_test(ser_repl, ser_data, bufsize, nbuf): assert bufsize % 256 == 0 # for verify to work + # how long to wait for data from device + # (if UART TX is also enabled then it can take 1.4s to send + # out a 16KB butter at 115200bps) + READ_TIMEOUT_S = 2 + # Load and run the read_test_script. ser_repl.write(b"\x03\x01\x04") # break, raw-repl, soft-reboot drain_input(ser_repl) @@ -121,7 +126,7 @@ def read_test(ser_repl, ser_data, bufsize, nbuf): while remain: t0 = time.monotonic_ns() while ser_data.inWaiting() == 0: - if time.monotonic_ns() - t0 > 1e9: + if time.monotonic_ns() - t0 > READ_TIMEOUT_S * 1e9: # timeout waiting for data from device break time.sleep(0.0001)