Assuming that the file that the LUA tutorial refers to ‘web.lua’ is actually ‘web_server.lua’. I can load this file onto my Fastrack Supreme and start the server:
$ web.start()
[WEB] Starting the web server
but when I attempt to connect with a broswer I get
$ [WEB] Starting new connection
run(): error: 192.168.192.5:8765/web_server.lua:44: attempt to call field
‘handle_connection’ (a nil value)
stack traceback: 192.168.192.5:8765/web_server.lua:44: in function <http://192.168
.192.5:8765/web_server.lua:44>
checking the channels
for n, ch in pairs (proc.channels) do
print("channel:", n, "port:", ch.port)
end
channel: 403635084 port: 23
channel: 403612972 port: 23
channel: 403662028 port: 80
How do I go about debugging this - I am happy to spend time learning how the language works but I need to start from some examples that should work if I follow the tutorial!
extra info.
I have my lua files served by the nanohttpd.jar mini server using http on port 8765 over PPP on UART1.
Firmware: R74a00gg.FSU004
LUA download: gcc_lua_interactive_256KB.wpb.dwl version shipped with M2M 1.1.1.200911160856-R3160
The function itself is defined in web_server.lua in around line 74:
-------------------------------------------------------------------------------
function web.handle_connection (cx)
while cx:state() == "ready" do -- Loop, don't close the connection
-- print "[WEB] Connection waiting for another request"
Thanks for your response.
Due to time constraints I will have to use openAT ‘c’ based code and maybe come back to LUA at a later date.
LUA has the perfect functionality for my project, similar to a previous project using Python but for some reason I’m finding working with LUA intermittent. If I load ‘web_server’ sometimes everything works as my original post and this allows me to debug as you suggested. But intermittently when I try loading ‘web_server’ although LUA says “web_server loaded OK” and “running…” if I type “=web” the response is “unknown variable” I have no idea when this will happen and it seems to be random when it starts working again. So although LUA says the code is loaded and running it’s not! Other simpler test programs always load and work OK.
This obviously makes debugging impossible and after many hours not being able to get even the tutorials working I’ll have to admit defeat…
Thanks
Al