Exit micropython from interrupt in c
Posted: Fri Oct 14, 2016 1:10 pm
Hello.
1. My uPy code is running in while loop.
2. I have timer interrupt implemented in c
- Is it possible to exit (break) executing uPy code from interrupt in c ?
I tried with: mp_obj_t exc = mp_obj_new_exception(&mp_type_SystemExit);
nlr_raise(exc);
which is sys.exit() function in uPy. After executing this code every interrupt is not working any more.
-I tried also this:
In interrupt global flag can be set.
Then I implemented my uPy module function which is checking if global flag is set. If yes its executing sys.exit().
In every while in uPy code I am checking the global flag. It works but I need to put addition code to every while loop.
- Is it possible to call sys.exit() in uPy interrupt ? My board is not ported and I cannot check it.
- I was also thinking about putting flags in place where script is interpreting, but I dont know where and I think, this is a lot of work.
If you have any idea let me know. Thank you !
1. My uPy code is running in while loop.
2. I have timer interrupt implemented in c
- Is it possible to exit (break) executing uPy code from interrupt in c ?
I tried with: mp_obj_t exc = mp_obj_new_exception(&mp_type_SystemExit);
nlr_raise(exc);
which is sys.exit() function in uPy. After executing this code every interrupt is not working any more.
-I tried also this:
In interrupt global flag can be set.
Then I implemented my uPy module function which is checking if global flag is set. If yes its executing sys.exit().
In every while in uPy code I am checking the global flag. It works but I need to put addition code to every while loop.
- Is it possible to call sys.exit() in uPy interrupt ? My board is not ported and I cannot check it.
- I was also thinking about putting flags in place where script is interpreting, but I dont know where and I think, this is a lot of work.
If you have any idea let me know. Thank you !