20.04.2016, 10:08
Something like this, though it will not work on older FW where grp.all function is not implemented.
Code:
if not client then
require('genohm-scada.eibdgm')
objects = grp.all()
datatypes = {}
for _, object in ipairs(objects) do
datatypes[ object.id ] = object.datatype
end
function writehandler(event)
local dpt = datatypes[ event.dstraw ]
if dpt then
local value = knxdatatype.decode(event.datahex, dpt)
end
end
function readhandler(event)
log(event)
end
client:sethandler('groupwrite', writehandler)
client:sethandler('groupresponse', writehandler)
client:sethandler('groupread', readhandler)
end
-- handle knx
client:step()