LUA错误的论点#2 [英] LUA bad argument #2

查看:105
本文介绍了LUA错误的论点#2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是LUA/ESP8266的初学者,我试图找出此错误的来源:

i am a total beginner with LUA / ESP8266 and i am trying to find out where this error comes from:

PANIC: unprotected error in call to Lua API (bad argument #2 to 'set' (index out of range))

这是串行监视器中的全部消息:

This is the Whole Message in serial monitor:

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-唤醒),并使用所有必需的模块构建了正确的NodeMCU固件.

I Uploaded this code (https://github.com/Christoph-D/esp8266-wakelight) to the ESP8266, and did build the correct NodeMCU firmware with all required modules.

串行输出在几秒钟内都正常,然后出现此错误,并且开始重复重新启动.

The Serial output is ok for a couple of seconds, then i get this error and it starts to repeat rebooting.

我将从哪里开始寻找问题?

Where would i start looking for the Problem?

非常感谢!

在lua文件中只有很少的地方写有关于设置"的任何内容:

there are only a few places in the lua files where anything about "set" is written:

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

有什么问题吗?

推荐答案

就在调用set的for循环上方,请尝试添加以下内容:

Just above the for-loop where set is called, try adding this:

print(buffer:size(), NUM_LEDS)

如果一切正常,它应该打印两次相同的数字.如果NUM_LEDS较大,那是您的错误.

If everything is OK, it should print the same number twice. If NUM_LEDS is larger, then that's your bug.

我真的不明白为什么它在那个地方使用全局变量.正是出于这个原因,使用buffer:size()代替会更有意义.

I don't really get why it uses the global variable in that place anyway; it'd make much more sense to use buffer:size() instead for exactly this reason.

这篇关于LUA错误的论点#2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆