我是LUA / ESP8266的初学者,我试图找出此错误的来源:
PANIC: unprotected error in call to Lua API (bad argument #2 to 'set' (index out of range))
这是串行监视器中的整个消息:
NodeMCU 2.2.0.0 built with Docker provided by frightanic.com
.branch: master
.commit: 11592951b90707cdcb6d751876170bf4da82850d
.SSL: false
.Build type: float
.LFS: disabled
.modules: adc,bit,dht,file,gpio,i2c,mqtt,net,node,ow,spi,tmr,uart,wifi
build created on 2019-12-07 23:52
powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)
> Config done, IP is 192.168.2.168
LED-Server started
PANIC: unprotected error in call to Lua API (bad argument #2 to 'set' (index out of range))
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 27780, room 16
tail 4
chksum 0xbc
load 0x3ffe8000, len 2188, room 4
tail 8
chksum 0xba
load 0x3ffe888c, len 136, room 0
tail 8
chksum 0xf2
csum 0xf2
å¬ú‰.Éo‰ísÉÚo|Ï.å.õd$`..#íú..æÑ2rí.lúN‡.Éo„..l`.Ñ‚r€lÑ$.å...l`.Ñ‚s≤pɉ$.å....l`.Ñ‚r€l.èæ.å...$l`.{$é.êo.Ñü¬cc.ÑÑ".|l.Bè.c.‰è¬.lc‰ÚnÓ.2NN‚....å#€‚n.ÏéÑ.l..$Ïådè|Ïl.é.lÄ.o¸.Ñæ.#".llÏÑè..c...åû„åc.l.Ñb.{$r.
我将此代码(https://github.com/Christoph-D/esp8266-wakelight)上传到ESP8266,并使用所有必需的模块构建了正确的NodeMCU固件。
串行输出在几秒钟内都正常,然后出现此错误,并且开始重复重启。
我将从哪里开始寻找问题?
非常感谢!
编辑:lua文件中只有很少的地方写有关于“ set”的任何内容:
local function update_buffer(buffer, c)
if not c.r_frac then c.r_frac = 0 end
if not c.g_frac then c.g_frac = 0 end
if not c.b_frac then c.b_frac = 0 end
local r2 = c.r_frac >= 0 and c.r + 1 or c.r - 1
local g2 = c.g_frac >= 0 and c.g + 1 or c.g - 1
local b2 = c.b_frac >= 0 and c.b + 1 or c.b - 1
local r3, g3, b3
local set = buffer.set
for i = 1, NUM_LEDS do
if i > c.r_frac then r3 = c.r else r3 = r2 end
if i > c.g_frac then g3 = c.g else g3 = g2 end
if i > c.b_frac then b3 = c.b else b3 = b2 end
set(buffer, i - 1, g3, r3, b3)
end
end
有什么问题吗?