Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
4cf5265c
Commit
4cf5265c
authored
Dec 30, 2014
by
funshine
Browse files
deal with uart.on api when required char number is 0
parent
265d2705
Changes
4
Show whitespace changes
Inline
Side-by-side
app/include/user_config.h
View file @
4cf5265c
...
...
@@ -2,7 +2,7 @@
#define __USER_CONFIG_H__
#define NODE_VERSION "NodeMcu 0.9.4"
#define BUILD_DATE "build 201412
26
"
#define BUILD_DATE "build 201412
30
"
#define FLASH_512K
// #define FLASH_1M
// #define FLASH_2M
...
...
app/lua/lua.c
View file @
4cf5265c
...
...
@@ -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
);
...
...
app/modules/uart.c
View file @
4cf5265c
...
...
@@ -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
;
...
...
examples/fragment.lua
View file @
4cf5265c
...
...
@@ -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
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment