我该如何解决这些随机错误,这些错误在每次发送到ESPlorer中的ESP时都会改变?

时间:2019-05-11 10:38:58

标签: arduino wifi arduino-uno ftdi esplorer

几个小时后,尝试使所有连接正确连接,什么都没连接,我偶然发现以下问题,每当我将其保存到我的esp(或发送)时,我都会收到随机错误,例如“无法写新行”或“预期。附近”。 [“ , 和更多。请在代码下面举一些例子。

esplorer中的代码

```

    -- Rui Santos
    -- Complete project details at https://randomnerdtutorials.com

    wifi.setmode(wifi.STATION)
    wifi.sta.config("K&M forever","ts0c4jjfygo")
    print(wifi.sta.getip())
    led1 = 3
    led2 = 4
    gpio.mode(led1, gpio.OUTPUT)
    gpio.mode(led2, gpio.OUTPUT)
    srv=net.createServer(net.TCP)
    srv:listen(80,function(conn)
        conn:on("receive", function(client,request)
            local buf = "";
            buf = buf.."HTTP/1.1 200 OK\n\n"
            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
                    _GET[k] = v
                end
            end

            if(_GET.pin == "ON1")then
                  gpio.write(led1, gpio.HIGH);
            elseif(_GET.pin == "OFF1")then
                  gpio.write(led1, gpio.LOW);
            elseif(_GET.pin == "ON2")then
                  gpio.write(led2, gpio.HIGH);
            elseif(_GET.pin == "OFF2")then
                  gpio.write(led2, gpio.LOW);
            end
            client:send(buf);
            client:close();
            collectgarbage();
        end)
    end)

```

错误越来越严重(一次总是只有一个错误):

```

stdin:2: attempt to call global 'w' (a romtable value)

stdin:1: attempt to call field 'writelinew' (a nil value)

stdin:1: unexpected symbol near '=='

stdin:1: unexpected symbol near '['

 ```

0 个答案:

没有答案