12.03.2021, 09:34
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
Ctrl+F5