1

I want to print my parsing value at Luci. Here is my code.

local val = {}
mm = Map("test", translate("For TEST"))
test=mm:section(TypedSection, "test", translate("TEST"))
test.anonymous = true
test.addremove = false

rssis = test:option(DummyValue, "rssi", translate("RSSI"))
t = test:option(DummyValue, "tx", translate("TX"))
r = test:option(DummyValue, "rx", translate("RX"))
local f = io.popen("iwpriv wlan0 stat")

for line in f:lines() do
    for s in line:gmatch("(%S+)%s") do
            table.insert(val, s)
    end

    for i, v in ipairs(val) do

    end
end
f:close()

rssis:value(val[35])

if val[41] == "6M" then
    t:value(val[41], translate("Disconnect"))
else
    t:value(33, translate("Good"))
end

if val[49] == "6M" then
    r:value(val[49], translate("DIsconnect"))
else
    r:value(33, translate("GOOD"))
end
return mm

I saw the DummyValue which Creates a readonly field in the form. So I used it instead of print function. However it has errors "attempt to index global 'rssis' (a nil value)"

Only in lua file(not used for Luci) If i used the print function, it has no error. Does Luci has print function?

darren
  • 103
  • 10
  • I don't understand how is indexing a nil value related to the print function in Lua? `test:option(DummyValue, "rssi", translate("RSSI"))` returns nil – Piglet Dec 14 '17 at 10:06
  • No, that prints the value which is saved in config file. I want to print the val to Luci that I parsed. – darren Dec 14 '17 at 10:43
  • what is that supposed to mean? what is "that"? the error you posted is caused by indexing the global rssis which refers to the return value of the call I mentioned in my last comment. rssis:value(val[35]) causes an error as rssis is nil. you must not index nil values! printing is completely irrelevant to that error. – Piglet Dec 14 '17 at 10:58
  • I found Dummy value have not an option t:value(val[41], translate("Disconnect")). When I delete that code, there has no error but It shows the saved value in config file. I want to display the val[41] in Luci. – darren Dec 14 '17 at 11:06

1 Answers1

3

There is a luci.util.perror("blah blah") function that prints to the syslog. you can then use the shell command "logread" to display in a console.

I guess this is what you need to debug your code.

J.P. Tosoni
  • 549
  • 5
  • 15