Syntax error background.lua line 12
With the new 1.0 lua scripts I get a syntax error in backgrounds.lua on line 12, attempt to index a nil vallue.
I'm own a X7 and the previous version 0.3 is working just fine.
Any ideas?
@codecae: Looks like a guard is needed for the case that getFieldInfo(protocol.stateSensor) returns nil.
It is hardcoded to both protocols. Not sure why this would occur. Perhaps @RadianceNL has an older version of protocols.lua.
I was more thinking of the getFieldInfo() call returning nil for whatever reason. But it could be caused by an older version of OpenTx. Is there a way to detect the OpenTx version in lua? If so, we should probably add a warning for users trying to run on an old version.
Perhaps a getVersion() fast fail as part of radios.lua is in order.
Here https://github.com/betaflight/betaflight-tx-lua-scripts/blob/master/src/SCRIPTS/BF/radios.lua#L38
Forgot to mention that I am running OpenTX 2.2.0 and as far as I know that is the latest version?
I've downloaded 1.0 from the release page and installed no heli, lua and multi module firmware version through the companion app.
It should work fine with 2.2 .. can you try deleting the scripts from your SD and recopy them?
On Sat, Nov 18, 2017, 4:24 PM RadianceNL [email protected] wrote:
Forgot to mention that I am running OpenTX 2.2.0 and as far as I know that is the latest version?
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/betaflight/betaflight-tx-lua-scripts/issues/90#issuecomment-345472382, or mute the thread https://github.com/notifications/unsubscribe-auth/AHyTqXKTgxS8XjKN8RiY6kdzVfMfVR98ks5s30sUgaJpZM4QjFhD .
Sure I will but I've already done that actually this afternoon. I will redownload the scripts and try again.
Edit: Recopied the files and still have the same error.
Try rediscovering sensors
Already done that as well, delete all sensors and then discover them again but didn't do the trick.
I use a R XSR btw with the latest FCC firmware.
@mikeller it looks like in the v1.0 zip that the return is on line 12. This should be fixed in master, right?
When I select the script I see bf, so no capital letters like the previous version had.
On my SD card I have bf.lua as well, not BF.lua
Do you have a Tmp1 sensor in your list of telemetry sensors?
Yes, it's reading 10011 to 30011 degrees celsius.
When I didn't had telementry I was able to start up the lua script but once telementry got recovered I get syntax error BF/MSP/common.lua line 107.
Attempt to perform arit.....
And after another reboot of the transmitter everything started to work...very strange but thanks a lot for the help.
Although I'm curious what happend
@codecae:
it looks like in the v1.0 zip that the return is on line 12. This should be fixed in master, right?
Looking at the zip, background.lua is:
mikeller@pc:~/tmp$ cat -n obj/SCRIPTS/BF/background.lua | head -20
1 local INTERVAL = 50 -- in 1/100th seconds
2 local MSP_SET_RTC = 246
3 local MSP_TX_INFO = 186
4
5 local lastRunTS
6 local sensorId = -1
7 local timeIsSet = false
8 local mspMsgQueued = false
9
10 local function getSensorValue()
11 if sensorId == -1 then
12 sensorId = getFieldInfo(protocol.stateSensor)['id'] or -1
13 end
14 return getValue(sensorId)
15 end
16
17 local function modelActive(sensorValue)
18 return type(sensorValue) == "number" and sensorValue > 0
19 end
20
To me it looks like there is something dodgy with sensor discovery, and that causes getFieldInfo() to return nil in some cases.
My hunch would be to leave it as it is for now (or do a quick fix fending against the nil return), and then rewrite the whole polling once betaflight/betaflight#4611 is in, and make it use MSP to query the status of RTC and RSSI, and act accordingly.
Miscounted the lines on my phone.. my bad :)
Yes, doesn't work for me either, I get the nil return from line 12 on background.lua as well
Here also. Just installed v1.0 and same error..
I'm getting nil return on line 12 also on a qx-7 and r-xsr with version 1. Running opentx2.2 newest release, internal module updated and the r-xsr. I have to turn off receiver to recover telemetry screen. But when it does work, it will change pids.