2024-03-29 07:11:05 发布
网友
我正在编写一个应用程序,它将通过连接到pc的USB集线器进行通信。我的问题是如何在python应用程序中检测连接到USB集线器的其他设备。我正在使用pyserial库通过USB进行通信
也许您可以尝试/使用pyUSB来实现以下目的:
#!/usr/bin/python import sys import usb.core # find USB devices dev = usb.core.find(find_all=True) # loop through devices, printing vendor and product ids in decimal and hex for cfg in dev: sys.stdout.write('Decimal VendorID=' + str(cfg.idVendor) + ' & ProductID=' + str(cfg.idProduct) + '\n') sys.stdout.write('Hexadecimal VendorID=' + hex(cfg.idVendor) + ' & ProductID=' + hex(cfg.idProduct) + '\n\n')
也许您可以尝试/使用pyUSB来实现以下目的:
相关问题 更多 >
编程相关推荐