This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

LM as a Modbus slave : number of slaves
#8
(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.
Reply


Messages In This Thread
RE: LM as a Modbus slave : number of slaves - by SigmaTec - 09.08.2022, 11:22

Forum Jump: