[libhid-discuss] match_serial_number and python
Li-Wei Chen
chen at vanu.com
Wed Apr 1 15:10:37 UTC 2009
Hi,
I'm successfully using libhid to talk to a single USB device, and I'd
ultimately like to be able to address multiple devices of the same model
from the same vendor. Happily, although each device has the same
vendor_id and product_id, the serial string associated with each device
is unique. In C, I'm able to follow the pattern in test_libhid.c to
modify match_serial_number appropriately and pass that in
HIDInterfaceMatcher to hid_force_open and select based on the serials.
I'm wondering if there's a way to accomplish the same thing using the
included python modules if I prefer to code in python as opposed to C.
I do see that there is a HIDInterfaceMatcher object, but test_libhid.py
only sets vendor_id and product_id properties. Digging into hid.h
further suggests that the matcher functionality available in C is not
available in python:
typedef struct HIDInterfaceMatcher_t {
unsigned short vendor_id;
unsigned short product_id;
#ifndef SWIG
matcher_fn_t matcher_fn; //!< Only supported in C library (not
via SWIG)
void* custom_data; //!< Only used by matcher_fn
unsigned int custom_data_length; //!< Only used by matcher_fn
#endif
} HIDInterfaceMatcher;
Can I correctly conclude from this that if I want to be able to match
USB devices based on their serials, I'll need to write my code in C?
Thanks,
-- Li-Wei
More information about the libhid-discuss
mailing list