20.11.2019, 16:09
Hello following the update of a HomeLynk I have my script for sending data on a IRIO that no longer works:
here is the error :
Resident script:20: attempt to index global 'cnv' (a nil value)
stack traceback:
Resident script:20: in function 'update_registers'
Do you have a solution to restore the connection?
Thanks.
B.R.
Code:
SLAVE_ADDRESS='192.168.70.246'
SLAVE_PORT=502
SLAVE_ID=1
NB=300 -- Number of coils, discrete inputs, holding registers and input registers
WORD=16
DWORD=32
function update_registers(knx_address,registre_nb,size)
val=grp.getvalue(knx_address)
if size==16 then
mb:setregisters(registre_nb,cnv.tonumber(val))
elseif size==32 then
shift=bit.rshift(cnv.tonumber(val),16)
mb:setregisters(registre_nb, shift,cnv.tonumber(val))
end
end
if not mb then
require('luamodbus')
mb = luamodbus.tcp()
--¤ Set correct parameters for the connection
t=mb:open(SLAVE_ADDRESS, SLAVE_PORT) -- TCP slave IP
--¤ Connection
o=mb:connect()
--¤ Set TCP slave address
mb:setslave(SLAVE_ID)
-- init slave storage for coils, discrete inputs, holding registers and input registers
mb:setmapping(0, 0, NB, 0)
end
update_registers("3/1/10",0,DWORD)
update_registers("3/2/10",2,DWORD)
update_registers("3/3/1",4,DWORD)
update_registers("3/3/2",6,DWORD)
update_registers("3/4/1",8,DWORD)
update_registers("3/4/2",10,DWORD)
update_registers("3/5/1",12,DWORD)
update_registers("3/5/2",14,DWORD)
update_registers("3/6/10",16,DWORD)
update_registers("2/0/0",18,DWORD)
update_registers("2/0/1",20,DWORD)
update_registers("2/0/2",22,DWORD)
update_registers("2/0/3",24,DWORD)
mb:handleslave()
Resident script:20: attempt to index global 'cnv' (a nil value)
stack traceback:
Resident script:20: in function 'update_registers'
Do you have a solution to restore the connection?
Thanks.
B.R.