This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Modbus 8bit low and high
#2
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
Reply


Messages In This Thread
Modbus 8bit low and high - by toujour - 11.03.2021, 15:54
RE: Modbus 8bit low and high - by Daniel - 12.03.2021, 09:34

Forum Jump: