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 connection status
#1
Hello, 

Do anyone know a good way to detect if there is or there is no connection with Modbus TCP device?

Code:
require('luamodbus')

mb = luamodbus.rtu()
mb:open('/dev/RS485-1', 9600, 'E', 8, 1, 'H')
mb:connect()

mb:setslave(1)
mb:setresponsetimeout(100)

--                     --
-- some modbus reading --
--                     --

mb:close()
Reply
#2
mb:connect() will return nil plus error message when connection cannot be established. If it breaks afterwards then all read/write calls will act the same.
Reply


Forum Jump: