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.

Read fire panel sensors current state
#1
Hi. I have a fire panel and want to read the state of each sensor by RS232. I´m new at LUA but made some things like this:

-- Include library before calling serial functions
if not port then
require('serial')
-- Setting port parameters and open serial port
port = serial.open('/dev/RS232', {
baudrate = 19200,
databits = 8,
stopbits = 1,
parity = 'none',
duplex = 'full'
})
-- Flushes any read/unsent bytes
port:flush()

-- Read data from serial port
if port:read() == 'Powr___1'
-- Send alert when condition matched
then alert('Projector is ON')
end

-- Closing serial port
port:close()
end

¿How do I enter this contact ID event for reading the current state of the sensor in LUA command. Attached is the contact ID events codes.

-- Read data from serial port
port:read() == 'Powr___1' 
end

¿Is there a "Hello world" command to see if the communication is established between LM and Fire panel?


Thanks for your help

Attached Files Thumbnail(s)
   
Reply
#2
Do you have documentation for the serial protocol?
Reply
#3
(24.01.2023, 07:12)admin Wrote: Do you have documentation for the serial protocol?

Just this.

Attached Files
.pdf   3102351-EN R005 VS1 and VS4 Technical Referenc.pdf (Size: 4.77 MB / Downloads: 11)
Reply
#4
Try running this script and see if you get anything in the Logs tab. Check that the panel is configured to send events to RS232.
Code:
if not port then
  port = require('serial').open('/dev/RS232', {
    baudrate = 19200,
  })

  buf = {}

  function logbuf()
    local txt = table.concat(buf)
    log(txt)
    buf = {}
  end
end

char, err = port:read(1, 1)
if char then
  if char == '\r' or char == '\n' then
    if #buf > 0 then
      logbuf()
    end
  else
    buf[ #buf + 1 ] = char

    if #buf == 100 then
      logbuf()
    end
  end
end
Reply


Forum Jump: