From 76ff5412443934970bb15dbe03b8c2da892d0961 Mon Sep 17 00:00:00 2001 From: TerryE Date: Fri, 11 Mar 2016 00:41:40 +0000 Subject: [PATCH] Prevent UART input race without extra lua_started flag --- app/lua/lua.c | 2 +- app/user/user_main.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/app/lua/lua.c b/app/lua/lua.c index cc1c1b95..8f9cf870 100644 --- a/app/lua/lua.c +++ b/app/lua/lua.c @@ -468,7 +468,7 @@ int lua_main (int argc, char **argv) { void lua_handle_input (bool force) { - if (force || readline (&gLoad)) + if (gLoad.L && (force || readline (&gLoad))) dojob (&gLoad); } diff --git a/app/user/user_main.c b/app/user/user_main.c index 290010bc..520a9a1d 100644 --- a/app/user/user_main.c +++ b/app/user/user_main.c @@ -80,19 +80,16 @@ void TEXT_SECTION_ATTR user_start_trampoline (void) call_user_start (); } -static bool lua_started=false; // +================== New task interface ==================+ static void start_lua(task_param_t param, uint8 priority) { char* lua_argv[] = { (char *)"lua", (char *)"-i", NULL }; NODE_DBG("Task task_lua started.\n"); lua_main( 2, lua_argv ); - lua_started=true; } static void handle_input(task_param_t flag, uint8 priority) { // c_printf("HANDLE_INPUT: %u %u\n", flag, priority); REMOVE - if (lua_started) - lua_handle_input (flag); + lua_handle_input (flag); } static task_handle_t input_sig;