File "F:\auart.py", line 49, in <module>
File "uasyncio/core.py", line 224, in get_event_loop
File "uasyncio/__init__.py", line 21, in __init__
File "uasyncio/core.py", line 30, in __init__
AttributeError: 'module' object has no attribute 'deque'
the code is:
Code: Select all
import uasyncio as asyncio
import gc
from pyb import UART
uart = UART(3, 9600)
async def sender():
Swriter = asyncio.StreamWriter(uart, {})
try:
while True:
await Swriter.awrite('READY\r\n12345265464563463463456346\r\n')
await asyncio.sleep_ms(10)
except asyncio.CancelledError:
print('Sender Cancelled')
async def receiver():
Sreader = asyncio.StreamReader(uart)
try:
while True:
res = await Sreader.readline()
#res = await Sreader.readexactly(5)
res_str = res.decode('utf-8')
if (res):
print("Received", res)
except asyncio.CancelledError:
print('Receiver Cancelled')
async def _gc():
while True:
await asyncio.sleep_ms(1)
gc.collect()
gc.threshold(gc.mem_free() // 4 + gc.mem_alloc())
gc.collect()
loop = asyncio.get_event_loop()
loop.create_task(sender())
loop.create_task(receiver())
loop.create_task(_gc())
loop.run_forever()