circuitpython/docs/pyboard/tutorial/pass_through.rst
Damien George b84268d49c docs/pyboard/tutorial: Add "timeout=0" to UART in pass-through example.
Without this the pass-through will pause for 1 second at each character.
2017-08-23 17:01:43 +10:00

19 lines
451 B
ReStructuredText

Making a UART - USB pass through
================================
It's as simple as::
import pyb
import select
def pass_through(usb, uart):
usb.setinterrupt(-1)
while True:
select.select([usb, uart], [], [])
if usb.any():
uart.write(usb.read(256))
if uart.any():
usb.write(uart.read(256))
pass_through(pyb.USB_VCP(), pyb.UART(1, 9600, timeout=0))