libusb:通过序列号获取设备
libusb 允许您通过供应商和产品 ID 查找设备。但是,如果我有多个附加了相同 VID 和 PID 的设备,并且想要通过知道其中一个设备的序列号来获取其句柄,该怎么办?有一个 libusb_open_device_with_vid_pid
,但没有 libusb_open_device_with_serial
或类似的。我是否必须爬行完整的设备列表(libusb_get_device_list
)还是有更方便的方法?
libusb lets you find a device by it's vendor and product ID. But what if I have several devices with the same VID and PID attached, and want to get a handle to one of them by knowing it's serial number? There is a libusb_open_device_with_vid_pid
, but no libusb_open_device_with_serial
or similar. Would I have to crawl though the full device list (libusb_get_device_list
) or is there a more convenient way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为爬行设备列表是唯一的方法。您可以从
libusb_open_device_with_vid_pid
复制代码,因为这正是该函数的作用。I think crawling through the device list is the only way here. You could copy the code from
libusb_open_device_with_vid_pid
, as that is precisely what this function does.