monocle-micropython
monocle-micropython copied to clipboard
Restarting (Ctrl+D) does not reset module's variables
All the custom C code of the modules would need to reset the variables to zero.
This is done by C at startup, but when rebooting MicroPython, the global variables contained within the modules might have invalid code.
For instance, callbacks might be pointing at invalid memory, or worse: working code that is not referred by malloc and might be overwritten at any time.
One possible solution is to use MicroPython __init__
, a single struct globals
for all global variables, and inside __init__
, memset the struct globals
to 0 (or default values).