How to fix script hanging?
How to fix script hanging?
I'm using MP as an embedded scripting engine for my firmware. I find that when there is an error in a script that MP waits in a loop and basically hangs my firmware. Is there a way to set micropython to just exit so that my firmware can continue regardless of script issues?
Re: How to fix script hanging?
I think that there is only a couple of places in the code where it does this, and these tend to be rather fatal errors.
One is the fatal error handler:
https://github.com/micropython/micropyt ... c#L82-L100
which should be accompanied by flashing LEDs.
With a serial REPL connected you can often see the message which would indicate more about why its failing.
Another place that this can happen (without the LEDs) is if an interrupt is enabled for which no handler has been written:
https://github.com/micropython/micropyt ... #L133-L135
It seems reasonable to me to have an option to have the system reset (like the RESET button was pushed) if one of these situations was encountered.
Another, more common approach is to use the Watchdog timer to trigger a system reset. Then if the system hangs for any reason at all you'll get a reset.
See this thread: viewtopic.php?f=5&t=226&p=5499#p5499
One is the fatal error handler:
https://github.com/micropython/micropyt ... c#L82-L100
which should be accompanied by flashing LEDs.
With a serial REPL connected you can often see the message which would indicate more about why its failing.
Another place that this can happen (without the LEDs) is if an interrupt is enabled for which no handler has been written:
https://github.com/micropython/micropyt ... #L133-L135
It seems reasonable to me to have an option to have the system reset (like the RESET button was pushed) if one of these situations was encountered.
Another, more common approach is to use the Watchdog timer to trigger a system reset. Then if the system hangs for any reason at all you'll get a reset.
See this thread: viewtopic.php?f=5&t=226&p=5499#p5499
Re: How to fix script hanging?
For my purpose I rather that MP exit and let my firmware continue running. The firmware functions have much higher priority than the mp scripts, and they can't be halted due to script errors.
Re: How to fix script hanging?
I'm also using the Minimal implementation of MP