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 Server logging writing IPs
#1
Hello.

On our LMs a Modbus TCP Server is running roughly based on https://openrb.com/lm-as-modbus-tcp-slave/
All works fine but at one customer something sporadically writes nonsens into our holding registers.
Is it possible to log the IP-address of the writing Client?
Adding a log(mb) to the function mbwriteregisters(register, value) does not gain the wanted result.

Thanks,
Christian
Reply
#2
You should use this script: https://forum.logicmachine.net/showthread.php?tid=4288

Modify the handler function in the resident script to alert IP/port for each connection:
Code:
123456789101112131415161718
local function handler(sock)   local ip, port = sock:getpeername()   alert('modbus connection from: %s:%d', ip, port)   copas.setErrorHandler(log)   sock = copas.wrap(sock)   sock:settimeout(60)   while true do     local res, err = mb.tcphandler(sock)     if not res then       break     end   end   sock:close() end
Reply
#3
Thanks for your support.
I will try the new version of the Modbus Server, but this will take some time.
Reply


Forum Jump: