04.03.2019, 17:25
hi.
I currently have a meter that has a modbus variable with 4 memory locations, someone knows how I can convert that variable to 32 bit format or higher
I was looking at this example, but I can not find out how I can do it
thank you
I currently have a meter that has a modbus variable with 4 memory locations, someone knows how I can convert that variable to 32 bit format or higher
Code:
-- init modbus on first script execution
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/ttyS2', 9600, 'E', 8, 1, 'H')
mb:connect()
end
-- sets slave ID to read/write data from/to
mb:setslave(20)
-- read 3-phase system voltage from 32-bit register
r1, r2 = mb:readregisters(0x1000, 2)
result = bit.lshift(r1, 16) + r2
grp.write('5/5/1',result)
-- read 3-phase system current from 32-bit register
r1, r2 = mb:readregisters(0x100E, 2)
result = bit.lshift(r1, 16) + r2
grp.write('5/5/2',result)
I was looking at this example, but I can not find out how I can do it
thank you