03.04.2018, 12:01
You can use socketping function but with port set to 502 (default ModBus TCP port):
Code:
function socketping(ip, port, timeout)
port = port or 80
local sock = require('socket').tcp()
sock:settimeout(timeout or 2)
local res, err = sock:connect(ip, port)
sock:close()
return res, err
end
ip = '192.168.10.150'
if not socketping(ip, 502) then
alert('device is offline')
end