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.

46 lines
794 B

  1. #!/usr/bin/env python
  2. import pyad2usb.ad2usb
  3. import time
  4. import signal
  5. import traceback
  6. running = True
  7. def signal_handler(signal, frame):
  8. global running
  9. running = False
  10. def handle_open(sender, args):
  11. print 'opened', args
  12. def handle_close(sender, args):
  13. print 'closed', args
  14. def handle_read(sender, args):
  15. print 'read', args
  16. def handle_write(sender, args):
  17. print 'write', args
  18. signal.signal(signal.SIGINT, signal_handler)
  19. try:
  20. wut = pyad2usb.ad2usb.AD2USB()
  21. wut.on_open += handle_open
  22. wut.on_close += handle_close
  23. wut.on_read += handle_read
  24. wut.on_write += handle_write
  25. wut.open()
  26. while running:
  27. time.sleep(0.1)
  28. wut.close()
  29. except Exception, err:
  30. print 'Error: {0}'.format(str(err))
  31. #traceback.print_exc(err)