Here's some TEST code for you
AND
a friendly request for solving the last major bug!
Select file htmllua.html in your browser. It contains a mix of HTML and LUA statements. The LUA statements are nicely executed and the results printed in the serial console. Like this:
Html:Hello. This HTML page contains a lua script<BR>
Lua-input:print("GPIO0="..gpio.read(8))
GPIO0=1
Lua-input:print("Chip="..node.chipid())
Chip=10116099
Lua-input:print("Heap="..node.heap())
Heap=6184
Lua-input:print("Lua executor : All lines in HTML file excuted")
Lua executor : All lines in HTML file excuted
The relevant code from init.lua is:
61 print("Lua-output:"..ln)
62 conn:send(ln)
Output from line 61 is visible in the serial console as the result from the executed Lua statement. That's excellent.
Output from line 61 refers the same variable and should be visible in the browser, but IT IS NOT.
I have a feeling that it is caused by "hidden" \r and or \n codes. I tried many things, but could not solve it yet.
Have a look please, maybe you will see something I have missed.
UPDATE : The resultline from the Lua execution does not come from line 61 !! It's from line 58. The lines 60/61/62 are never executed now! Line 58 executes the Lua statement OK, but does not return the result to the string, but prints it at the console. Grrrrrrrrrrrrr. Don't know how to fix it yet.
54 while line ~= "?>" do
55 if line then
56 print("Lua-input:"..line)
57 linef=loadstring(line)
58 ln=linef()
59 if ln then
60 ln = string.gsub(ln,"\n","")
61 print("Lua-output:"..ln)
62 conn:send(ln)
63 end