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.

check slave tcp/IP modbus device status
#5
(23.11.2020, 08:35)admin Wrote: You should use checkwrite and also send false when there's no error. This will send true when delta is more than 4 minutes, false otherwise:
Code:
grp.checkwrite('1/1/1', delta1 > 240)

Status is not updated because there's a response from the gateway. "Illegal data address" is not a connection error. There's a special error code 11 (Gateway Target Device Failed to Respond) that should have been used for this.

ok understood !
Adding a column error in modbus_device or mapping could be a solution...


In my case, if I check every adress, it should be too much cpu load no ??
I was thinking to something like this:
What's your point ?

Code:
function checkSlaveTcpModbus(resultCheckTemp)
  local retour_modbus = ''
  local heartbeat_time = 5 -- Minutes
  local now = os.time() -- current timestamp in seconds
 
  local res = db:getall('SELECT name, updatetime FROM objects WHERE (address>?) AND (address<?)', 39999, 50000)

  if res then
    for _, liste_modbus in ipairs(res) do
      if (now - liste_modbus.updatetime) >= (heartbeat_time * 60) then
          retour_modbus=retour_modbus .. '[' ..liste_modbus.name ..']'
      end
      end
  end
  --log( retour_modbus)
  return retour_modbus
end
-----------
FRANCE SMARTHOME & SMARTBUILDING INTEGRATION
SE ECO EXPERT
Reply


Messages In This Thread
RE: check slave tcp/IP modbus device status - by domotiqa - 23.11.2020, 08:53

Forum Jump: