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.

35 lines
904 B

  1. import time
  2. from alarmdecoder import AlarmDecoder
  3. from alarmdecoder.devices import SocketDevice
  4. # Configuration values
  5. HOSTNAME = 'localhost'
  6. PORT = 10000
  7. def main():
  8. """
  9. Example application that opens a device that has been exposed to the network
  10. with ser2sock or similar serial-to-IP software.
  11. """
  12. try:
  13. # Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.
  14. device = AlarmDecoder(SocketDevice(interface=(HOSTNAME, PORT)))
  15. # Set up an event handler and open the device
  16. device.on_message += handle_message
  17. with device.open():
  18. while True:
  19. time.sleep(1)
  20. except Exception as ex:
  21. print('Exception:', ex)
  22. def handle_message(sender, message):
  23. """
  24. Handles message events from the AlarmDecoder.
  25. """
  26. print(sender, message.raw)
  27. if __name__ == '__main__':
  28. main()