Current Lua downloadable firmware will be posted here

User avatar
By scargill
#3065 I was getting SO excited...

So I took the new webserver example, added a counter - and checked for an argument like www.mysite.com/?myarg=HELLO

Looked up the LUA docs - found the way to do it and


> mycounter=0
> srv=net.createServer(net.TCP)
> srv:listen(80,function(conn)
>> conn:on("receive",function(conn,payload)
>> if string.find(payload,"?myarg=") then
>> mycounter=mycounter+1
>> m="<br/>Value= " .. string.sub(payload,string.find(payload,"?myarg=")+7,string.find(payload,"HTTP")-2)
>> else
>> m=""
>> end
>> conn:send("<h1> Hello, this is Pete's web page.</h1>How are you today.<br/> Count=" .. mycounter .. m)
>> end)
>> conn:on("sent",function(conn) conn:close() end)
>> end)
>



Absolutely GREAT... but ran it a dozen times, the counter worked, the argument came back and then.... I have NO idea why it crashed.



> c_GORSvfJSz.Szfn
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4
>
Loading functions
Connecting
Connected to.loft-east.IP:.0.0.0.0
OK
User avatar
By zeroday
#3068
scargill wrote:Checked out the examples... despite being able to effortlessly load up the startup routine and other functions, loading the new example telnet crashes the board at different points when I try it - I'm leaving 400ms between sending each line.

Here's what happened with the example Telnet... as you can see - part way through - a reboot.


Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4
>
Loading functions
Connecting
Connected to.loft-east.IP:.192.168.0.22
OK

> function startServer()
>> print("Wifi AP connected. Wicon IP:")
>> print(wifi.sta.getip())
>> sv=net.createServer(net.TCP, 180)
>> sv:listen(8080, function(conn)
>> print("Wifi console connected.")
>>
>> function s_output(str)
>> if (conn~=nil) then
>> conn:send(str)
>> end
>> end
>> node.output(s_output,0)
>>
>> conn:on("receive", function(conn, pl)
>> node.input(pl)
c_GORSvfJSzfJSzfn
Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4


Same thing happens here, typing incomplete lines in serial.

It is not because of the telnet.lua it-self. Every function with more than 26/27 lines will cause this issue.
You can use file.write to save telnet.lua to flash. and dofile("telnet.lua") to run it for now.

too many (>26) incomplete line input from serial, will reset the unit.
incomplete line means a prompt ">>" shows to wait for another line.
I will debug this.