Print exceptuons from main.py to serial

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
amartino
Posts: 6
Joined: Mon Feb 20, 2017 11:00 am

Print exceptuons from main.py to serial

Post by amartino » Mon Feb 20, 2017 11:04 am

Hello all :)

Is there a way to have the exceptions in main.py be printed on the serial console?
This is the best idea I have so far for debugging non reproducible issues with main.py

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Print exceptuons from main.py to serial

Post by dhylands » Mon Feb 20, 2017 7:34 pm

You can put the REPL on a UART using os.dupterm() (also pyb.repl_uart on pyboard), and then everything that shows up on the REPL will also show up on the serial port.

There is also sys.print_exception: http://docs.micropython.org/en/latest/p ... _exception

Post Reply