From 646f1eaf806de7fc894f67808421ee3604151598 Mon Sep 17 00:00:00 2001 From: arne Date: Sun, 5 Oct 2025 12:10:19 +0200 Subject: [PATCH] Ensure that boot script is run in uninterrupted task. --- main/inkpot.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main/inkpot.c b/main/inkpot.c index 50201e0..b6d0d65 100644 --- a/main/inkpot.c +++ b/main/inkpot.c @@ -237,6 +237,10 @@ esp_err_t http_draw(httpd_req_t* req) { } // TODO: Error handling + // TODO: Ensure that `run_lua_string` is executed in an uninterrupted task; + // this means we need to set the task prio of the current request. + // Execute the Lua script received as post body; this is executed as a + // FreeRTOS task that will not be interrupted run_lua_string(buf, "E-Paper Script via HTTP"); heap_caps_free(buf); @@ -285,8 +289,13 @@ void app_main(void) { register_http_routes(server); } - // Run script in assets/epaper.lua - run_lua_file("epaper.lua", "E-Paper Startup Script"); + // Run script in assets/epaper.lua; this is executed as a FreeRTOS task + // that may not be interrupted + void runLuaFile (void* arg) { + run_lua_file("epaper.lua", "E-Paper Startup Script"); + vTaskDelete(NULL); + } + xTaskCreate(runLuaFile, "run_lua_file", 4096, NULL, tskIDLE_PRIORITY, NULL); ESP_LOGI(TAG, "End of application.");