adding uartloop module for turning a micropython board into a serial adapter

This commit is contained in:
Matthew Connelly 2018-07-12 14:39:04 +01:00
parent c3a644d60e
commit 2544f4d2f6
1 changed files with 13 additions and 0 deletions

13
uartloop.py Normal file
View File

@ -0,0 +1,13 @@
import pyb
def UARTPassThruLoop(bus_usb, bus_uart):
bus_usb.setinterrupt(-1)
while True:
if bus_usb.any(): bus_uart.write(bus_usb.read(256))
if bus_uart.any(): bus_usb.write(bus_uart.read(256))
def UARTPassThru(id_uart, baud_uart):
uart=pyb.UART(id_uart,baud_uart,timeout=75,timeout_char=75)
usb=pyb.USB_VCP()
print("Now entering UART passthru loop. To exit, reset.")
UARTPassThruLoop(usb, uart)