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.

60 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. #dev = pyad2usb.ad2usb.AD2USB()
  27. #dev = overseer.get_device()
  28. dev = pyad2usb.ad2usb.Overseer.create()
  29. dev.on_open += handle_open
  30. dev.on_close += handle_close
  31. dev.on_read += handle_read
  32. dev.on_write += handle_write
  33. dev.open()
  34. while running:
  35. time.sleep(0.1)
  36. dev.close()
  37. overseer.close()
  38. #wut.close()
  39. except Exception, err:
  40. #print 'Error: {0}'.format(str(err))
  41. traceback.print_exc(err)