1-byte value comes from the example that you gave in another thread, that I tried to understand. I have no clue to be honest.
In this register there are 32 writable bits, some of them are reserved though.
https://forum.logicmachine.net/showthrea...24#pid6824
Bit 4 (bypass) and bit 5 (out of bypass) are exclusive as they both control the state of the UPS. I can only write true to one of them because it toggles between thoose states, either bypass or online.
Am I in the ball park with this script? Setting bit 4 in 1536 to true.
In this register there are 32 writable bits, some of them are reserved though.
https://forum.logicmachine.net/showthrea...24#pid6824
Bit 4 (bypass) and bit 5 (out of bypass) are exclusive as they both control the state of the UPS. I can only write true to one of them because it toggles between thoose states, either bypass or online.
Am I in the ball park with this script? Setting bit 4 in 1536 to true.
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('192.168.1.228', 502)
mb:connect()
mb:setslave(11)
function setbit(value, nr)
return bit.bor(value, bit.lshift(1, nr))
end
value = 1
value = setbit(value, 4)
mb:writeregisters(1536, value)
mb:close()
log(value) -- result: 17