串口

  1. import log
  2. log.basicConfig(level=log.INFO)
  3. Testlog = log.getLogger("TestLog")
  4. # 设置输出到debug口
  5. from machine import UART
  6. uart = UART(UART.UART0, 115200, 8, 0, 1, 0)
  7. log.set_output(uart)
  8. Testlog.info("this is a Test log") # 会输出到对应的uart口
  9. # 从uart口切换成交互口输出
  10. import usys
  11. log.set_output(usys.stdout)
  12. Testlog.info("this is a Test log") # 会输出到交互口