Posts: 106
Threads: 40
Joined: Sep 2017
Reputation:
0
Hi,
how can I create a profile (or a Script ) to read and write this modbus word (Register 21) ?
BR,
Alberto
KNX Advanced Partner + Tutor
Posts: 4646
Threads: 24
Joined: Aug 2017
Reputation:
207
Try this, you may need to subtract -1 from the register.
Code:
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 9600, 'E', 8, 1, 'H')
mb:connect()
end
mb:setslave(1)
value = mb:readregisters(21)
address = bit.rshift(value, 8)
baudrate = value-address*256
log(address,baudrate)
newaddress = 2
newbaudrate = 1
reg=newaddress*256 + newbaudrate
mb:writeregisters(21, reg)
------------------------------
Ctrl+F5