[libhid-discuss] finding multile devices
Warren Jasper
wjasper at tx.ncsu.edu
Sun Jan 13 00:15:22 UTC 2008
Yes, that is exactly what I want to do, write a custom matcher
function. However, please look at line 86 in hid_opening.c
usb_claim_interface(usbdev_h, hidif->interface);
in the function hid_find_usb_device. The subroutine is traversing the
usbbuses and usbdevices looking for a device to compare
(send to hid_compare_usb_device). There is no check on the return to
usb_claim_interface(). If the interface is already claimed
by a previous call to that device, why would I want to proceed? Now the
matcher function does not know if that device/interface
has been previously claimed. This is ONLY a problem for the case I am
interested in, where there are multiple devices of
the same type, otherwise the vendor and product won't match. Should
this line not read:
if (usb_claim_interface(usbdev_h, hidif->interface)) continue; //
returns 0 on success
Now I am "more" certain that devices that need to be matched have NOT
been matched previously.
Warren
Charles Lepple wrote:
> [please keep the list CC'd.]
>
> On Jan 12, 2008, at 10:48 AM, Warren Jasper wrote:
>
>> I think you missed my point. When searching the bus for a match,
>> there should be a helper function that returns either:
>>
>> 1. ALL the devices that match (could be more than one)
>
> Most people are using one device at a time. You might have an argument
> for an extra function that returns a list of opened device handles,
> though.
>
>> 2. Subsequent calls need to return matched devices that have not been
>> open.
>
> I understand exactly what you're looking for here, and what I was
> saying is that checking with the hid_is_opened() function can only
> prove that something in that process (or thread, really) has opened
> that interface. That won't catch the device/interface being opened by
> another library, program or thread.
>
> That said, my suggestion about keeping a list inside your code would
> work. The custom matcher function doesn't have to match against serial
> numbers - it can also check against a list of devices that your code
> has previously opened. The reason why I am suggesting this before
> changing libhid code is that it means you don't have to wait for a new
> release of libhid to get this functionality, and you can test this
> idea to make sure there isn't something wrong with my reasoning.
>
More information about the libhid-discuss
mailing list