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.

Modbus TCP debug
#2
This example will create Modbus TCP slave on port 502. It will log all requests/responses.
Code:
require('luamodbus')

mb = luamodbus.tcp()
mb:open('0.0.0.0', 502)

mb:setmapping(0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF)

debug = {}

mb:setdebug(function(ch)
  debug[ #debug + 1 ] = ch
end)

while true do
  mb:handleslave()

  if #debug > 0 then
    log(table.concat(debug))
    debug = {}
  end
end
Reply


Messages In This Thread
Modbus TCP debug - by MarcusH - 09.09.2022, 19:39
RE: Modbus TCP debug - by admin - 12.09.2022, 06:07

Forum Jump: