09.08.2022, 11:22
(09.08.2022, 10:11)admin Wrote: 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):
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()
Result :
* arg: 1
* string: connect failed
* arg: 2
* string: Connection refused
But to be sure we are on the same subject :
my deal is to use LM as Modbus slave in order to write in it some registers which will be read by a master.