Esplorer会削减代码吗? <eof>预计接近'end'NodeMCU

时间:2017-06-07 08:41:19

标签: lua nodemcu

我的代码工作正常。然后我使用Pyflasher(在另一台计算机和另一个端口上)使用相同的包重新刷新了firware。代码停止正常工作。我收到了很多错误(主题中提到了一个错误,第二个错误可能是“预计会关闭”(')。我已计算thenend并搜索错误。我想知道是否Esplorer就是这样做的: 而不是:
 local k = 5 print(k)
它就是这样的:

loca l k = 5print(k)
这会产生错误。
你有没有遇到过这个问题(和解决方案)? 的代码

led1 = 4
licznik = 1
gpio.mode(led1, gpio.OUTPUT)
tempcz = 0
tempok = 0
czassy = {2000000000, 2, 2000000000, 2, 2000000000, 2, 2000000000, 2, 2000000000, 2}
rtctime.set(1000, 0)

station_cfg={}
station_cfg.ssid="Dom"
station_cfg.pwd="31323334353637383931323334"
wifi.sta.config(station_cfg)
function receive(conn, request)
        print(request)
        print()
        local buf = "";
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
            _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        end
        local _GET = {}
        if (vars ~= nil)then
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do -- vars = pin=ON1, k na lewo od "="
                _GET[k] = v                                     -- a v na prawo od "="
                   if (string.match(string.sub(v, 1, 1), '[0-9]') ~= nil) then --pierwszy element stringa
                    czassy[licznik] = v
                    licznik = licznik + 1                    
                    if (licznik == 11) then
                        licznik = 0;
                    end
                end
            end
        end
        buf = buf.."<h1> ESP8266 Web Server</h1>";
        buf = buf.."<form method=\"get\" action=\"http://192.168.1.10/\"><input type=\"text\" name=\"data1\"><input type=\"submit\" value=\"Wyślij1\">"
        buf = buf.."<input type=\"text\" name=\"okres1\"><input type=\"submit\" value=\"WyślijO1\"></form>";               
        buf = buf.."<p>GPIO0 <a href=\"?pin=ON1\">";
        buf = buf.."<button>ON</button></a>&nbsp;<a href=\"?pin=OFF1\"><button>OFF</button></a></p>";

        local _on,_off = "",""
        if(_GET.pin == "ON1")then
              gpio.write(led1, gpio.HIGH);
        elseif(_GET.pin == "OFF1")then
              gpio.write(led1, gpio.LOW);
        end
        conn:on("sent", function(sck) sck:close() end)
        conn:send(buf);
        collectgarbage();
end

function connection(conn) 
    conn:on("receive", receive) -- laczy callbackowe funkcje receive z odpowiednimi zdarzeniami - jak receive lub sent
end

srv=net.createServer(net.TCP, 1) 
srv:listen(80, connection) -- cconnection TO: callback function, pass to caller function as param if a connection is created successfully




mytimer = tmr.create()
mytimer1 = tmr.create()
mytimer:register(2000, tmr.ALARM_AUTO, function() 
    aktualny, usec = rtctime.get()
    if(aktualny > tonumber(czassy[1])) then
         czassy[1] = 2000000000
         palenie(czassy[2])
    elseif (aktualny > tonumber(czassy[3])) then
         czassy[3] = 2000000000
         palenie(czassy[4])
    elseif (aktualny > tonumber(czassy[5])) then
         czassy[5] = 2000000000
         palenie(czassy[6])
    elseif (aktualny > tonumber(czassy[7])) then
        czassy[7] = 2000000000
        palenie(czassy[8])
    elseif (aktualny > tonumber(czassy[9])) then
         czassy[9] = 2000000000
         palenie(czassy[10])  
    end      
end)
mytimer:start()
function palenie(okres)
    gpio.write(led1, gpio.LOW);
    mytimer1:register(okres, tmr.ALARM_SINGLE, function() gpio.write(led1, gpio.HIGH); end);
     mytimer1:start();
end

0 个答案:

没有答案