File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed
Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 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.
67import uasyncio as asyncio
78from machine import UART
9+
810uart = UART (4 , 9600 , timeout = 0 )
911
12+
1013async 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+
1721async 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
2328async def main ():
2429 asyncio .create_task (sender ())
2530 asyncio .create_task (receiver ())
2631 while True :
2732 await asyncio .sleep (1 )
2833
34+
2935def 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
3845test ()
You can’t perform that action at this time.
0 commit comments