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.

58 lines
1.1 KiB

  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. def handle_attached(sender, args):
  19. print 'attached', args
  20. def handle_detached(sender, args):
  21. print 'detached', args
  22. signal.signal(signal.SIGINT, signal_handler)
  23. try:
  24. overseer = pyad2usb.ad2usb.Overseer(attached_event=handle_attached, detached_event=handle_detached)
  25. #overseer.start()
  26. """wut = pyad2usb.ad2usb.AD2USB()
  27. wut.on_open += handle_open
  28. wut.on_close += handle_close
  29. wut.on_read += handle_read
  30. wut.on_write += handle_write
  31. wut.open()"""
  32. while running:
  33. time.sleep(0.1)
  34. overseer.stop()
  35. #wut.close()
  36. except Exception, err:
  37. print 'Error: {0}'.format(str(err))
  38. #traceback.print_exc(err)