deal with uart.on api when required char number is 0
This commit is contained in:
parent
265d27058b
commit
4cf5265ccc
|
@ -2,7 +2,7 @@
|
|||
#define __USER_CONFIG_H__
|
||||
|
||||
#define NODE_VERSION "NodeMcu 0.9.4"
|
||||
#define BUILD_DATE "build 20141226"
|
||||
#define BUILD_DATE "build 20141230"
|
||||
#define FLASH_512K
|
||||
// #define FLASH_1M
|
||||
// #define FLASH_2M
|
||||
|
|
|
@ -678,6 +678,12 @@ void ICACHE_FLASH_ATTR readline(lua_Load *load){
|
|||
|
||||
ch = 0;
|
||||
}
|
||||
|
||||
if( (load->line_position > 0) && (!run_input) && (need_len==0) && (end_char<0) )
|
||||
{
|
||||
uart_on_data_cb(load->line, load->line_position);
|
||||
load->line_position = 0;
|
||||
}
|
||||
// if there is no input from user, repeat readline()
|
||||
os_timer_disarm(&readline_timer);
|
||||
os_timer_setfn(&readline_timer, (os_timer_func_t *)readline, load);
|
||||
|
|
|
@ -28,7 +28,7 @@ bool ICACHE_FLASH_ATTR uart_on_data_cb(const char *buf, size_t len){
|
|||
|
||||
uint16_t need_len = 0;
|
||||
int16_t end_char = -1;
|
||||
// Lua: uart.on("method", function, [run_input])
|
||||
// Lua: uart.on("method", [number/char], function, [run_input])
|
||||
static int ICACHE_FLASH_ATTR uart_on( lua_State* L )
|
||||
{
|
||||
size_t sl, el;
|
||||
|
|
|
@ -307,5 +307,6 @@ wifi.sta.setip({ip="192.168.18.119",netmask="255.255.255.0",gateway="192.168.18.
|
|||
uart.on("data","\r",function(input) if input=="quit\r" then uart.on("data") else print(input) end end, 0)
|
||||
uart.on("data","\n",function(input) if input=="quit\n" then uart.on("data") else print(input) end end, 0)
|
||||
uart.on("data", 5 ,function(input) if input=="quit\r" then uart.on("data") else print(input) end end, 0)
|
||||
uart.on("data", 0 ,function(input) if input=="q" then uart.on("data") else print(input) end end, 0)
|
||||
|
||||
uart.on("data","\r",function(input) if input=="quit" then uart.on("data") else print(input) end end, 1)
|
||||
|
|
Loading…
Reference in New Issue