summaryrefslogtreecommitdiffstatshomepage
path: root/docs/tutorial/pass_through.rst
blob: a94e7363d2160bae169ac1c852c58b38e21c8632 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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))