Skip to content

Commit e815e9b

Browse files
committed
auart.py: Add code comment re timeout.
1 parent 024b080 commit e815e9b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

v3/as_demos/auart.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,43 @@
33
# Copyright Peter Hinch 2017-2022 Released under the MIT license
44
# Link X1 and X2 to test.
55

6+
# We run with no UART timeout: UART read never blocks.
67
import uasyncio as asyncio
78
from machine import UART
9+
810
uart = UART(4, 9600, timeout=0)
911

12+
1013
async def sender():
1114
swriter = asyncio.StreamWriter(uart, {})
1215
while True:
13-
swriter.write('Hello uart\n')
16+
swriter.write("Hello uart\n")
1417
await swriter.drain()
1518
await asyncio.sleep(2)
1619

20+
1721
async def receiver():
1822
sreader = asyncio.StreamReader(uart)
1923
while True:
2024
res = await sreader.readline()
21-
print('Received', res)
25+
print("Received", res)
26+
2227

2328
async def main():
2429
asyncio.create_task(sender())
2530
asyncio.create_task(receiver())
2631
while True:
2732
await asyncio.sleep(1)
2833

34+
2935
def test():
3036
try:
3137
asyncio.run(main())
3238
except KeyboardInterrupt:
33-
print('Interrupted')
39+
print("Interrupted")
3440
finally:
3541
asyncio.new_event_loop()
36-
print('as_demos.auart.test() to run again.')
42+
print("as_demos.auart.test() to run again.")
43+
3744

3845
test()

0 commit comments

Comments
 (0)