Skip to content

Commit 29b5c22

Browse files
committed
tests/extmod_hardware/machine_uart_irq_rxidle.py: Test multiple writes.
This tests that the RXIDLE callback is called correctly after a second lot of bytes are received. Signed-off-by: Damien George <damien@micropython.org>
1 parent a4a098f commit 29b5c22

File tree

2 files changed

+33
-11
lines changed

2 files changed

+33
-11
lines changed

tests/extmod_hardware/machine_uart_irq_rxidle.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,13 @@ def irq(u):
6464
print("IRQ_RXIDLE:", bool(u.irq().flags() & u.IRQ_RXIDLE), "data:", u.read())
6565

6666

67-
text = "12345678"
67+
text = ("12345678", "abcdefgh")
6868

6969
# Test that the IRQ is called for each set of byte received.
7070
for bits_per_s in (2400, 9600, 115200):
71+
print("========")
72+
print("bits_per_s:", bits_per_s)
73+
7174
if tx_pin is None:
7275
uart = UART(uart_id, bits_per_s)
7376
else:
@@ -81,10 +84,11 @@ def irq(u):
8184
# Configure desired IRQ.
8285
uart.irq(irq, uart.IRQ_RXIDLE)
8386

84-
# Write data and wait for IRQ.
85-
print("write", bits_per_s)
86-
uart.write(text)
87-
uart.flush()
88-
print("ready")
89-
time.sleep_ms(100)
90-
print("done")
87+
for i in range(2):
88+
# Write data and wait for IRQ.
89+
print("write")
90+
uart.write(text[i])
91+
uart.flush()
92+
print("ready")
93+
time.sleep_ms(100)
94+
print("done")
Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
write 2400
1+
========
2+
bits_per_s: 2400
3+
write
24
ready
35
IRQ_RXIDLE: True data: b'12345678'
46
done
5-
write 9600
7+
write
8+
ready
9+
IRQ_RXIDLE: True data: b'abcdefgh'
10+
done
11+
========
12+
bits_per_s: 9600
13+
write
614
ready
715
IRQ_RXIDLE: True data: b'12345678'
816
done
9-
write 115200
17+
write
18+
ready
19+
IRQ_RXIDLE: True data: b'abcdefgh'
20+
done
21+
========
22+
bits_per_s: 115200
23+
write
1024
ready
1125
IRQ_RXIDLE: True data: b'12345678'
1226
done
27+
write
28+
ready
29+
IRQ_RXIDLE: True data: b'abcdefgh'
30+
done

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy