A clone of: https://github.com/nutechsoftware/alarmdecoder This is requires as they dropped support for older firmware releases w/o building in backward compatibility code, and they had previously hardcoded pyserial to a python2 only version.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
861 B

  1. import time
  2. from alarmdecoder import AlarmDecoder
  3. from alarmdecoder.devices import SerialDevice
  4. SERIAL_DEVICE = '/dev/ttyUSB0'
  5. BAUDRATE = 115200
  6. def main():
  7. """
  8. Example application that prints messages from the panel to the terminal.
  9. """
  10. try:
  11. # Retrieve the first USB device
  12. device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
  13. # Set up an event handler and open the device
  14. device.on_lrr_message += handle_lrr_message
  15. with device.open(baudrate=BAUDRATE):
  16. while True:
  17. time.sleep(1)
  18. except Exception as ex:
  19. print('Exception:', ex)
  20. def handle_lrr_message(sender, message):
  21. """
  22. Handles message events from the AlarmDecoder.
  23. """
  24. print(sender, message.partition, message.event_type, message.event_data)
  25. if __name__ == '__main__':
  26. main()