所以,我在我的OS X Lion(10.7.3)机器上安装了libusb和pyUSB,我运行了以下脚本:
import usb
import time
if __name__ == "__main__":
while True:
busses = usb.busses()
print busses[0]
print busses[0].__dict__
time.sleep(2)
我插入了一个USB设备:SanDisk cruzer micro,4GB。我可以在Finder和磁盘工具中打开此闪存驱动器而不会出现问题。但是,上述脚本的输出是:
<usb.legacy.Bus object at 0x108defe10>
{'dirname': '', 'devices': [], 'localtion': 0}
<usb.legacy.Bus object at 0x108ef4610>
{'dirname': '', 'devices': [], 'localtion': 0}
<usb.legacy.Bus object at 0x108defe10>
{'dirname': '', 'devices': [], 'localtion': 0}
<usb.legacy.Bus object at 0x108ef4610>
{'dirname': '', 'devices': [], 'localtion': 0}
至少表明pyUSB的第一个也是唯一一个总线不相信目前有任何设备连接。我错过了某种基本设置吗?为什么pyUSB找不到我的设备?
我一直在引用这个StackOverflow问题开始:usb device identification