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.

mb:setregisters() and LM values
#6
Modbus does not define word/byte order so there are 4 different ways of encoding an int64 value.

Try this:
Code:
value = grp.getvalue('32/1/1')

raw = knxdatatype.encode(value, dt.int64).dataraw

r1 = raw:byte(1) * 0x100 + raw:byte(2)
r2 = raw:byte(3) * 0x100 + raw:byte(4)
r3 = raw:byte(5) * 0x100 + raw:byte(6)
r4 = raw:byte(7) * 0x100 + raw:byte(8)

register = 3204
mb:setregisters(register, r1)
mb:setregisters(register+1, r2)
mb:setregisters(register+2, r3)
mb:setregisters(register+3, r4)

And this:
Code:
value = grp.getvalue('32/1/1')

raw = knxdatatype.encode(value, dt.int64).dataraw

r1 = raw:byte(2) * 0x100 + raw:byte(1)
r2 = raw:byte(4) * 0x100 + raw:byte(3)
r3 = raw:byte(6) * 0x100 + raw:byte(5)
r4 = raw:byte(8) * 0x100 + raw:byte(7)

register = 3204
mb:setregisters(register, r4)
mb:setregisters(register+1, r3)
mb:setregisters(register+2, r2)
mb:setregisters(register+3, r1)
Reply


Messages In This Thread
mb:setregisters() and LM values - by SigmaTec - 08.08.2022, 05:55
RE: mb:setregisters() and LM values - by admin - 08.08.2022, 08:59

Forum Jump: