Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format) ran the risk of filling up the task queue, preventing the start_lua task from being queued, and hence NodeMCU would not start up that time.
This commit is contained in:
parent
a86fb74c34
commit
90c6e86872
|
@ -330,7 +330,6 @@ uart_init(UartBautRate uart0_br, UartBautRate uart1_br, os_signal_t sig_input)
|
|||
uart_config(UART0);
|
||||
UartDev.baut_rate = uart1_br;
|
||||
uart_config(UART1);
|
||||
ETS_UART_INTR_ENABLE();
|
||||
#ifdef BIT_RATE_AUTOBAUD
|
||||
uart_init_autobaud(0);
|
||||
#endif
|
||||
|
|
|
@ -29,11 +29,8 @@
|
|||
#include "rtc/rtctime.h"
|
||||
#endif
|
||||
|
||||
#define SIG_LUA 0
|
||||
#define SIG_UARTINPUT 1
|
||||
#define TASK_QUEUE_LEN 4
|
||||
static task_handle_t input_sig;
|
||||
|
||||
static os_event_t *taskQueue;
|
||||
|
||||
/* Note: the trampoline *must* be explicitly put into the .text segment, since
|
||||
* by the time it is invoked the irom has not yet been mapped. This naturally
|
||||
|
@ -58,19 +55,17 @@ 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 );
|
||||
// Only enable UART interrupts once we've successfully started up,
|
||||
// otherwise the task queue might fill up with input events and prevent
|
||||
// the start_lua task from being posted.
|
||||
ETS_UART_INTR_ENABLE();
|
||||
}
|
||||
|
||||
static void handle_input(task_param_t flag, uint8 priority) {
|
||||
// c_printf("HANDLE_INPUT: %u %u\n", flag, priority); REMOVE
|
||||
(void)priority;
|
||||
lua_handle_input (flag);
|
||||
}
|
||||
|
||||
static task_handle_t input_sig;
|
||||
|
||||
task_handle_t user_get_input_sig(void) {
|
||||
return input_sig;
|
||||
}
|
||||
|
||||
bool user_process_input(bool force) {
|
||||
return task_post_low(input_sig, force);
|
||||
}
|
||||
|
@ -118,7 +113,8 @@ void nodemcu_init(void)
|
|||
#endif
|
||||
// endpoint_setup();
|
||||
|
||||
task_post_low(task_get_id(start_lua),'s');
|
||||
if (!task_post_low(task_get_id(start_lua),'s'))
|
||||
NODE_ERR("Failed to post the start_lua task!\n");
|
||||
}
|
||||
|
||||
#ifdef LUA_USE_MODULES_WIFI
|
||||
|
|
Loading…
Reference in New Issue