device filtering support
Hans de Goede
hdegoede at redhat.com
Wed Feb 8 10:54:40 EST 2012
Hi,
On 02/08/2012 04:44 PM, Pete Batard wrote:
> On 2012.02.08 14:26, Hans de Goede wrote:
>> So a question from my side, what do people think about adding
>> such functions to libusb? Good or bad idea?
>
> In other words, you want libusb to perform some caching of various fairly static and enumeration-related USB properties that the OS can provide (possibly with querying, since there's no guarantee that all OSes will cache these internally), so that any libusb app can reference them, before attempting to open a device.
>
> Personally, I think that libusb should indeed be able to provide a cached copy of all the descriptors you listed, as well as topology and speed data, or any kind of information we can obtain that is not expected to change for the duration of the device's presence. So obviously, I see it as a good idea.
>
> Wouldn't it be great, then, if libusb had a cross platform process that did this kind of caching once per user session and handled enumeration and hotplug...?
>
> What you describe is uncannily close to the potential problem I've been trying to solve. Again, the problem is we'd like to have the OS provide us much of the static USB data (descriptors, topology) we want to make readily available in libusbx at all times, and do that, as much as possible, in a cross platform manner, with caching, and with as few bus queries as possible.
Right / agreed. A number of remarks though:
1) A process to cache these is not necessary on Linux, as the kernel has all
these cached and provides them in sysfs. If Mac OS X needs to do the caching in libusb,
I'm fine with solving this cross platform, but would prefer a way to disable the "caching daemon"
under Linux since it is not needed there. If windows is the only one where the OS does not
cache these then it might be best to just solve this with something windows specific.
2) When I said "adding such functions to libusb" I was actually talking about adding the following
2 functions:
int libusb_get_device_manufacturer_string(libusb_device *dev, char *buf, int buf_len);
int libusb_get_device_product_string(libusb_device *dev, char *buf, int buf_len);
Which would first call a platform specific function to get the manufacturer / product strings
from the device without opening it (as the user may not have the rights to open the device) and
if that fails, lookup the vid + pid in usb.ids to return the relevant string.
So rephrasing my question: What do people think about adding
the 2 proposed functions to libusb? Good or bad idea?
Regards,
Hans
More information about the libusbx
mailing list