pass_through.rst 451 B

123456789101112131415161718
  1. Making a UART - USB pass through
  2. ================================
  3. It's as simple as::
  4. import pyb
  5. import select
  6. def pass_through(usb, uart):
  7. usb.setinterrupt(-1)
  8. while True:
  9. select.select([usb, uart], [], [])
  10. if usb.any():
  11. uart.write(usb.read(256))
  12. if uart.any():
  13. usb.write(uart.read(256))
  14. pass_through(pyb.USB_VCP(), pyb.UART(1, 9600, timeout=0))