Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.10 branch - getFieldInfo(<number>) returns nil instead of table #5210

Closed
1 task done
JimB40 opened this issue Jun 22, 2024 · 1 comment
Closed
1 task done

2.10 branch - getFieldInfo(<number>) returns nil instead of table #5210

JimB40 opened this issue Jun 22, 2024 · 1 comment
Labels
bug 🪲 Something isn't working lua-api Lua API related triage Bug report awaiting review / sorting
Milestone

Comments

@JimB40
Copy link
Collaborator

JimB40 commented Jun 22, 2024

Is there an existing issue for this problem?

  • I have searched the existing issues

What part of EdgeTX is the focus of this bug?

Transmitter firmware

Current Behavior

There is nasty bug introduced in 2.10 branch that will affect many LUA scripts

getFieldInfo() can take as argument field name or source list index number.
In case argument is source list index function returns nil instead of table

TX16S as example
getFieldInfo('sa') is returning proper table
getFieldInfo(126) is returning nil

Expected Behavior

getFieldInfo() has to return table

Steps To Reproduce

Testing script

local toolName = "TNS|Sources|TNE"

return {
  run = function(e)
    lcd.clear()
    local swID = getSourceIndex(CHAR_SWITCH..'SA')
    lcd.drawText(0,0,swID,0)
    local swName = getSourceName(swID)
    lcd.drawText(0,20,swName,0)
    local swValue = getSourceValue('sa')
    lcd.drawText(0,40,tostring(swValue),0)

    lcd.drawText(0,80,'getFieldInfo('..swID..')',0)
    local fieldInfo = getFieldInfo(swID)
    if fieldInfo ~= nil then
      lcd.drawText(0,100,fieldInfo.id,0)
      lcd.drawText(0,120,fieldInfo.name,0)
      lcd.drawText(0,140,fieldInfo.desc,0)
    else
      lcd.drawText(0,100,'field info is nil',0)
    end

    lcd.drawText(200,80,'getFieldInfo("sa")',0)
    local fieldInfo = getFieldInfo('sa')
    if fieldInfo ~= nil then
      lcd.drawText(200,100,fieldInfo.id,0)
      lcd.drawText(200,120,fieldInfo.name,0)
      lcd.drawText(200,140,fieldInfo.desc,0)
    else
      lcd.drawText(200,100,'Field info is nil',0)
    end

    return 0
  end,

}

Output on 2.9.4
screenshot_tx16s_24-06-22_09-55-04

Output on 2.10 and 2.10.1
screenshot_tx16s_24-06-22_09-54-25

Version

2.10.1

Transmitter

RadioMaster TX16S / TX16SMK2

Operating System (OS)

macOS

OS Version

No response

Anything else?

No response

@JimB40 JimB40 added bug 🪲 Something isn't working triage Bug report awaiting review / sorting labels Jun 22, 2024
@JimB40 JimB40 added this to the 2.10.2 milestone Jun 22, 2024
@JimB40 JimB40 added the lua-api Lua API related label Jun 22, 2024
@philmoz
Copy link
Collaborator

philmoz commented Jun 22, 2024

Already fixed in PR #5108

@JimB40 JimB40 closed this as completed Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🪲 Something isn't working lua-api Lua API related triage Bug report awaiting review / sorting
Projects
None yet
Development

No branches or pull requests

2 participants