Last active
January 4, 2016 22:09
-
-
Save walac/8685660 to your computer and use it in GitHub Desktop.
Test of the openusb backend for PyUSB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from usb.core import find | |
from usb.backend import openusb | |
import sys | |
if len(sys.argv) < 2: | |
print ('Usage: python test-openusb.py idvendor:idproduct (in hex)') | |
exit(1) | |
vendor, product = list(map(lambda x: int(x, 16), sys.argv[1].split(':'))) | |
b = openusb.get_backend() | |
if b is None: | |
print ('OpenUSB not found') | |
exit(1) | |
device = find(backend=b, idVendor=vendor, idProduct=product) | |
if device is None: | |
print ('Device not found') | |
exit(1) | |
print (device.product) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment