since days I try to get rid of this issue every now and then.
I'm running MicroPython as a FreeRTOS task on a nrf52832 dk. When I power the board my (frozen) main.py runs as intended. main.py itself depends on several (frozen) modules for playing sound, handle button events, blinking leds and stuff like that.
But every now and then I need to restart the python task. This (from what I thought) could be done easily with FreeRTOS by calling:
Code: Select all
vTaskDelete( taskHandleMpyRepl );
Code: Select all
xTaskCreate(mpy_task, "REPL", 800, NULL, 0, &taskHandleMpyRepl);
Code: Select all
static uint32_t heap[MP_HEAP_SIZE];
static char *stack_top;
void mpy_task(void *pvParameter)
{
SEGGER_RTT_printf(0, "mpy :: task\n");
volatile uint32_t sp;
stack_top = (char *) &sp;
mp_stack_set_top((void *)&sp);
gc_init(heap, heap + MP_HEAP_SIZE);
mp_init();
mpy_exec();
}
void mpy_exec(void)
{
pyexec_frozen_module("main.py");
}
Code: Select all
main
Traceback (most recent call last):
File "main.py", line 57, in <module>
File "main.py", line 51, in main
AttributeError: no such attribute
Code: Select all
[...]
# main loop
def main():
print('main') #this is printed
#play ON melody on startup
snd.play_melody(on_melody) #this is line 51 where traceback starts
#fsm.run() runs an infinite loop
fsm_init()
if __name__ == "__main__":
main()
Thanks for hanging on to this line
Chris