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.

Script to Monitor Remote System -
#1
Hi

I have a script which I use to monitor the zones in a remote alarm system.    It's a looping script which processes the data coming in from a socket connection.  I need one instance of the script running continuously.

What's the best place to locate this (script below) - is it as a resident script with a 0 interval time or as an init script or somewhere else?

Many thanks in advance

Kind Regards,
James




Code:
-- Initialise socket connection
if not sock then
  require('socket')

  sock, err = socket.connect('192.168.1.100', 2401)
  if sock then
    sock:settimeout(1)
  else
    log('Error connecting ' .. err)
    sleep(5)
  end
end


-- Process data received
if sock then   
 
  while true do
    rec = sock:receive('*l')

    if rec then
      
      data = lmcore.hextostr(rec, true)
      st, addr, len, cmd, event, id, area = data:byte(1, 7)
 
        if (event == 0) then
          log('Door open in Zone ' .. id)
        else
          log('Door closed in Zone ' .. id)
        end
     
    end
  end
 
end
Reply


Messages In This Thread
Script to Monitor Remote System - - by jamesng - 03.10.2022, 12:42

Forum Jump: