04.09.2020, 07:29 
		
	
	
		You can check it like this
	
	
	
Code:
-- First parameter is slave ID, second is optional RTU port number (1, 2 or 3; default is 1)
function checkrtu(slave, portnr)
  local query = 'SELECT active FROM modbus_devices WHERE proto="rtu" AND slave=? AND portnr=?'
  if type(portnr) == 'number' and portnr == 2 or portnr == 3 then
    portnr = portnr - 1
  else
    portnr = 0
  end
  local res = db:getone(query, slave, portnr)
  return toboolean(res)
end
function checktcp(ip, port)
  local settings, res
  settings = tostring(ip) .. ':' .. tostring(port)
  res = db:getone('SELECT active FROM modbus_devices WHERE proto="tcp" AND settings=?', settings)
  return toboolean(res)
end
------------------------------
Ctrl+F5
	
Ctrl+F5
 
 

