circuitpython/tests/circuitpython-manual/busio/uart_echo.py

19 lines
396 B
Python
Raw Normal View History

import busio
import board
import time
i = 0
u = busio.UART(tx=board.TX, rx=board.RX)
while True:
u.write(str(i).encode("utf-8"))
time.sleep(0.1)
2021-03-15 09:57:36 -04:00
print(i, u.in_waiting) # should be the number of digits
time.sleep(0.1)
2021-03-15 09:57:36 -04:00
print(i, u.in_waiting) # should be the number of digits
r = u.read(64 + 10)
2021-03-15 09:57:36 -04:00
print(i, u.in_waiting) # should be 0
print(len(r), r)
i += 1