Current Lua downloadable firmware will be posted here

User avatar
By scargill
#3053 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
User avatar
By scargill
#3055 One down, one to go.

GREAT. I tried this version of the web server and up to now I cannot crash it.. It is not hard to see how one could extract some GET information out of that to do something useful. We are getting somewhere.

However, could you take a look at your new Telnet example- I've detailed elsewhere - I can't even manage to load it in.

Pete.


zeroday wrote:
scargill wrote:So I did some more tests this morning.

Examples from here: https://github.com/nodemcu/nodemcu-firmware

The TELNET example does not work and results in the module resetting every time..

The Web page example looks exciting at first.. but I noticed the browser returned the result "Hello NodeMCU but was constantly busy... and as browsers do, it retries the page.. and after 5 retries, the ESP-01 resets. Here's the output I monitored on the serial.

So here is the power up sequence and my init file getting an address from the router - all of that works..

Pete's LUA module 0.1
NodeMcu 0.9.2 build 20141120 powered by Lua 5.1.4
> c_GORSvfJSz.JSzfn
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


and then here is where I add in the web page example


> srv=net.createServer(net.TCP)
> srv:listen(80,function(conn)
>> conn:on("receive",function(conn,payload)
>> print(payload)
>> conn:send("<h1> Hello, NodeMcu.</h1>")
>> end)
>> end)
>


and then here is the result...

> GET / HTTP/1.1
Host: 192.168.0.22
Connection: keep-alive
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Linux; Android 5.0; Nexus 10 Build/LRX21P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.59 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6


but then wait... the browser of course gets the page again... and again. and....

GET / HTTP/1.1
Host: 192.168.0.22
Connection: keep-alive
Cache-Control: max-age=0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Linux; Android 5.0; Nexus 10 Build/LRX21P) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.59 Safari/537.36
Accept-Encoding: gzip, deflate, sdch
Accept-Language: en-GB,en-US;q=0.8,en;q=0.6


PANIC: unprotected error in call to Lua API (attempt to call a nil value)
c_GORSvf
SzfJSzfn
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

So a quick test suggests it works - but in fact after a few refreshes - the unprotected error occurs and the board resets.


I got the same error, after 10+ refreshes.
sorry, some examples need more tests, before it's writen in the doc.
the code below disconnect with client when payload is sent. may be it's better, still little tests made.

Code: Select allsrv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
   print(payload) print(node.heap())
   conn:send("<h1> Hello, NodeMcu.</h1>")
   end)
conn:on("sent",function(conn) conn:close() end)
end)
User avatar
By scargill
#3057 Another query - when running the likes of the little web server - still working a treat!! It shows the heap size - around 9k. I assume that's RAM. Where are functions held... in RAM or FLASH and if the latter - any rough idea of how much is available? i.e. as we get ambitious are we going to run out of room?