我没有正确理解 USB 协议,因此在添加 USB 时对获取有关 USB 的数据的代码感到困惑。我不知道我哪里出错了。我的系统是 Windows 8 64 位。
有一个重大错误,我也需要帮助。
import usb.core
import usb.util
# Find our device
dev = usb.core.find(find_all=True)
busses = usb.busses()
# Was it found?
if dev is None:
raise ValueError('Device not found')
for bus in busses:
devices = bus.devices
for dev in devices:
try:
_name = usb.util.get_string(dev.dev, 19, 1)
except:
continue
dev.set_configuration()
cfg = dev.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
alternate_settting = usb.control.get_interface(interface_number)
print "Device name:",_name
print "Device:", dev.filename
print " idVendor:",hex(dev.idVendor)
print " idProduct:",hex(dev.idProduct)
for config in dev.configurations:
print " Configuration:", config.value
print " Total length:", config.totalLength
print " selfPowered:", config.selfPowered
print " remoteWakeup:", config.remoteWakeup
print " maxPower:", config.maxPower
print
这是我得到的错误:
import usb.backend.libusb10 as libusb10
ImportError: No module named backend.libusb10