Microcontroller Quitting Mid-Script
Microcontroller Quitting Mid-Script
I have scripts calling into c-functions and then going back to python specific code. I am trying to handle the case where the script jumps into a c function and incorrectly sets/gets a out of bounds value. At that point, I need to kill the script completely and return up the stack to where the script was initially executed from. This is running on a standalone micro controller with no keyboard or console attached. Suggestions. Thanks!
Re: Microcontroller Quitting Mid-Script
rasie an exception which is only caught by the code at the start point.
Re: Microcontroller Quitting Mid-Script
I have this same question. Are you suggesting a long jump? Will re-initializing python from within the C function work?
Re: Microcontroller Quitting Mid-Script
You can raise an exception from C by using nlr_raise. This will get caught by the python code. nlr_raise is essentially a longjmp.
You can also raise a SystemExit exception which will essentially do a soft reboot.
You can also raise a SystemExit exception which will essentially do a soft reboot.