vpelletier / python-libusb1

Python ctype-based wrapper around libusb1
GNU Lesser General Public License v2.1
168 stars 65 forks source link

opening 2 devices with same vendorID and productID #44

Closed wjasper closed 2 years ago

wjasper commented 5 years ago

It would be great if openByVendorIDAndProductID() took an optional argument serialNumber. That way, if there were two or more USB devices with the same vendorID and productID, there would be an easy way to get a usb handle on the correct one. The default could be serialNumber =None to just return the first device that was not already open.

vpelletier commented 5 years ago

Hello,

openByVendorIDAndProductID is intended to map libusb_open_device_with_vid_pid from the C library. Quoting the documentation:

This function is intended for those scenarios where you are using libusb to knock up a quick test application - it allows you to avoid calling libusb_get_device_list() and worrying about traversing/freeing the list.

IOW, it's a simple helper for simple needs, more complex needs should call the elementary underlying methods (get list of devices, get descriptors, decide what/how to match, maybe also involve hotplug support where supported, ...).

vpelletier commented 2 years ago

I close this, as I do not think python-libusb1 can cover all enumeration cases, so this is probably best left for the application to implement.