Uart CR & LF Handling
Posted: Mon Dec 22, 2014 11:15 am
LS,
Running NodeMCU 20121222.
When using the function uart.on("data", function(data) .... end)
Using CR as line ending:
The parameter data contains :
- first receive -> all characters until CR
- next receives -> CR + characters received
Using CRLF ending
The parameter data contains :
- first receive -> all characters until CR
- next receives -> LF + characters received
And there is still the previous mentioned ">" response, also when run_unit parameter = 0.
I am using the following test program.
Running NodeMCU 20121222.
When using the function uart.on("data", function(data) .... end)
Using CR as line ending:
The parameter data contains :
- first receive -> all characters until CR
- next receives -> CR + characters received
Using CRLF ending
The parameter data contains :
- first receive -> all characters until CR
- next receives -> LF + characters received
And there is still the previous mentioned ">" response, also when run_unit parameter = 0.
I am using the following test program.
Code: Select all
uart.setup( 0, 9600, 8, 0, 1, 0 )
uart.on("data",
function(data)
-- for i=1, string.len(data) do print (i) print(string.byte(data,i)) end
-- print("receive ",string.len(data)," chars from uart: ", data, " First = ", string.byte(data))
if data=="quit" then
uart.on("data")
uart.setup( 0, 9600, 8, 0, 1, 1 )
end
end, 0)