Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import usb.core
  2. import usb.util
  3.  
  4. # find our device
  5. dev = usb.core.find(idVendor=0xfffe, idProduct=0x0001)
  6.  
  7. # was it found?
  8. if dev is None:
  9. raise ValueError('Device not found')
  10.  
  11. # set the active configuration. With no arguments, the first
  12. # configuration will be the active one
  13. dev.set_configuration()
  14.  
  15. # get an endpoint instance
  16. cfg = dev.get_active_configuration()
  17. intf = cfg[(0,0)]
  18.  
  19. ep = usb.util.find_descriptor(
  20. intf,
  21. # match the first OUT endpoint
  22. custom_match = \
  23. lambda e: \
  24. usb.util.endpoint_direction(e.bEndpointAddress) == \
  25. usb.util.ENDPOINT_OUT)
  26.  
  27. assert ep is not None
  28.  
  29. # write the data
  30. ep.write("^KNzebra,aaa")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement