01.08.2020, 07:43
As suggested earlier you should use a profile instead of a script.
Here's a script that handles disconnect correctly. Make sure that script sleep time is larger than 0.
Here's a script that handles disconnect correctly. Make sure that script sleep time is larger than 0.
Code:
if not mb then
require('luamodbus')
mb = luamodbus.tcp()
mb:open('192.168.0.162', 502)
res = mb:connect()
log('stato modebus', res)
end
if mb then
value = mb:readinputregisters(9216)
log('valore di value', value)
if not value then
mb:close()
mb = nil
end
end