09.08.2022, 10:11
First, check the Error log for any errors.
You can use this test script for reading from local TCP slave with port 502 (check Logs tab for the read result or any errors):
You can use this test script for reading from local TCP slave with port 502 (check Logs tab for the read result or any errors):
Code:
require('luamodbus')
mb = luamodbus.tcp()
mb:open('127.0.0.1', 502)
res, err = mb:connect()
if res then
val, err = mb:readregistervalue(3204, 'int64', 'b')
if val then
log('read ok', val)
else
log('read failed', err)
end
else
log('connect failed', err)
end
mb:close()