12.07.2024, 11:08
Hello, maybe you can help me, how can I send the value only to 8bit, because if I use this script everything works, but it also activates 1bit as an example.
I want to send the value only as an example 8bit
require('luamodbus')
mb = luamodbus.tcp()
mb:open('10.30.0.242', 8000)
mb:connect()
mbetslave(1)
bendra_reiksme = mb:readregisters(1000)
function setbit(value, bitnr)
local mask = bit.lshift(1, bitnr)
return bit.bor(value, mask)
end
value = setbit(1, 8)
mb:writeregisters(1000, value)
mb:close()
I want to send the value only as an example 8bit
require('luamodbus')
mb = luamodbus.tcp()
mb:open('10.30.0.242', 8000)
mb:connect()
mbetslave(1)
bendra_reiksme = mb:readregisters(1000)
function setbit(value, bitnr)
local mask = bit.lshift(1, bitnr)
return bit.bor(value, mask)
end
value = setbit(1, 8)
mb:writeregisters(1000, value)
mb:close()