import usb.core
import usb.util
# Find the USB device
dev = usb.core.find(idVendor=0x1234, idProduct=0x5678)
# Claim the USB interface
interface = 0
usb.util.claim_interface(dev, interface)
# Receive data over USB
data = dev.read(1, 1024)
# Release the USB interface
usb.util.release_interface(dev, interface)
# Print the received data
print(data)
1条答案
按热度按时间uxhixvfz1#
你可以使用PyUSB,首先安装它
pip install pyusb
,然后使用下面的脚本,不要忘记将供应商ID和产品ID替换为你拥有的ID。