4

我目前正在研究 PyUSB。由于我是 USB 新手,我不知道如何执行以下操作。

我已从 Python PyUSB 成功连接到我的 USB 设备硬件。在我需要重置 USB 设备硬件的代码中。我通过向硬件发送命令来做到这一点。现在硬件重置后,我想从 Python PyUSB 释放当前的 USB 设备。然后我想在重置后再次连接到 USB 设备硬件。

请告诉我,如何释放 USB 设备连接和接口等以便重新连接?

非常感谢您提前。

4

2 回答 2

4
#!/usr/bin/python
from usb.core import find as finddev
dev = finddev(idVendor=0x1234, idProduct=0x5678)
dev.reset()
于 2016-12-25T21:55:08.450 回答
3
my_device = usb.core.find(...)

...

# necessary to allow further claim_interface calls
#   (bulk read), generally not needed
usb.util.dispose_resources(my_device)
于 2015-01-23T15:43:16.147 回答