run MicroPython v1.9.4-241-g14ab81e on my ESP8266 nodemcu board.
load
Code: Select all
import uasyncio as asyncio
from machine import UART
uart = UART(0, 115200)
async def sender():
swriter = asyncio.StreamWriter(uart, {})
while True:
await swriter.awrite('Hello uart\n')
await asyncio.sleep(2)
async def receiver():
sreader = asyncio.StreamReader(uart)
while True:
res = await sreader.readline()
print('Recieved', res)
loop = asyncio.get_event_loop()
loop.create_task(sender())
loop.create_task(receiver())
loop.run_forever()
and got the following output
Hello uart
Hello uart
Hello uart
Traceback (most recent call last):
File "main.py", line 20, in <module>
File "uasyncio/core.py", line 77, in run_forever
File "uasyncio/__init__.py", line 69, in wait
KeyboardInterrupt:
MicroPython v1.9.4-241-g14ab81e on 2018-07-04; ESP module with ESP8266
Type "help()" for more information.
>>> asdf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'asdf' is not defined
>>>
I expected to get the typed input printed out: Recieved asdf
As I understand the typed input is passed to stdin and not to sreader.readline().
Any help is welcome.
Regards
Kurt