14.02.2020, 14:29
Thank you very much both!
So this script is correct if I wanna set Bit0 of register 1280 to 0 when 32/1/1's value is 1
And another question the 123 near the code below what value is??
So this script is correct if I wanna set Bit0 of register 1280 to 0 when 32/1/1's value is 1
Code:
function setbit(value, bitnr)
local mask = bit.lshift(1, bitnr)
return bit.bor(value, mask)
end
value = 0
if grp.getvalue('32/1/1') then
value = setbit(value, 0)
end
log(value)
mb = require('mbproxy').new()
mb:setslave(1)
-- set register at address 1000 to 123
mb:writeregisters(1280, 0)
mb:close()
Code:
-- set register at address 1000 to 123