12.07.2024, 11:13
Try this:
The recommended approach is to use profiles.
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('10.30.0.242', 8000)
mb:connect()
mb:setslave(1)
value = mb:readregisters(1000)
function setbit(value, bitnr)
local mask = bit.lshift(1, bitnr)
return bit.bor(value, mask)
end
value = setbit(value, 8)
mb:writeregisters(1000, value)
mb:close()
The recommended approach is to use profiles.