I am trying to generate a list of product/vendor IDs with Pyusb and I am having trouble. I found a suggestion online from orangecoat.
import sys
import usb.core
import usb.util
dev = usb.core.find(find_all=True)
if dev is None:
raise ValueError('Device not found')
cfg = dev.get_active_configuration()
Python gives the following error though:
Traceback (most recent call last):
File "C:/Python27/usbfinddevices.py", line 10, in <module>
cfg = dev.get_active_configuration()
AttributeError: 'generator' object has no attribute 'get_active_configuration'
Could someone help me understand why I am getting this error? Thank you
Save this script
test.py
import usb.core
import usb.util
dev = usb.core.find(find_all=True)
# get next item from the generator
d = dev.next()
print d.get_active_configuration()
then, run this
sudo python test.py
On Windows with Python 3 you need to change line d = dev.next()
to d = next(dev)
(as pointed out in the comments by @gabin)