8000 tests/serial_test.py: Allow up to 2 seconds between bytes. · micropython/micropython@2762fe6 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2762fe6

Browse files
projectgusdpgeorge
authored andcommitted
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 <angus@redyak.com.au>
1 parent 10b7dfd commit 2762fe6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/serial_test.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,11 @@ def read_test(ser_repl, ser_data, bufsize, nbuf):
103103

104104
assert bufsize % 256 == 0 # for verify to work
105105

106+
# how long to wait for data from device
107+
# (if UART TX is also enabled then it can take 1.4s to send
108+
# out a 16KB butter at 115200bps)
109+
READ_TIMEOUT_S = 2
110+
106111
# Load and run the read_test_script.
107112
ser_repl.write(b"\x03\x01\x04") # break, raw-repl, soft-reboot
108113
drain_input(ser_repl)
@@ -121,7 +126,7 @@ def read_test(ser_repl, ser_data, bufsize, nbuf):
121126
while remain:
122127
t0 = time.monotonic_ns()
123128
while ser_data.inWaiting() == 0:
124-
if time.monotonic_ns() - t0 > 1e9:
129+
if time.monotonic_ns() - t0 > READ_TIMEOUT_S * 1e9:
125130
# timeout waiting for data from device
126131
break
127132
time.sleep(0.0001)

0 commit comments

Comments
 (0)
0