Discussion:
[libhid-discuss] Using multiple HID devices with same vendor / product ID
Sarah Mount
2008-11-16 15:01:56 UTC
Permalink
Hi All,

I'm trying to communicate with a number of HID devices at once, using
the Python bindings for libhid(*). I know this has been covered in the
list before and I've looked over the discussion here:
http://lists.alioth.debian.org/pipermail/libhid-discuss/2008-January/000336.html

However, I'm still a bit confused over how libhid works. Turning on
debugging I notice that HIDInterfaceMatcher objects do indeed find all
HID devices on the USB bus, but I can't see any way to get to that
list from the SWIG interface. Obviously(?) asking the matcher to open
a device twice results in an error, not in two devices being opened,
as discussed in the other thread.

Is it actually possible to do what I'm trying to do from the Python
bindings? Presumably I need to subclass HIDInterfaceMatcher to
manipulate the internal list of matched devices, but will this have to
be done in the C library and if so where would be best to start
looking -- hid_opening.c or linux.c?

Many thanks,

Sarah


(*) Ubuntu Ibex GNU/Linux
python-hid 0.2.15+20060325-2.1
libhid0 0.2.15+20060325-2.1
libusb 1:0.1.5-1
Python2.5
--
Sarah Mount, Senior Lecturer, University of Wolverhampton
Web: http://www.wlv.ac.uk/~in0316/
Book: http://www.pythonforrookies.org/
Blog: http://varspool.blogspot.com/
Photos: http://flickr.com/photos/sarahmount/

This email, together with any attachment, is for the exclusive and
confidential use of the addressee(s) and may contain legally
privileged information. Any use, disclosure or reproduction without
the sender's explicit consent is unauthorised and may be unlawful.

Any e-mail including its content and any attachments may be monitored
and used by The University of Wolverhampton for reasons of security
and for monitoring internal compliance with the University's policy on
internet use. E-mail blocking software may also be used. The
University cannot guarantee that this message or any attachment is
virus free or has not been intercepted and amended.

If you believe you have received this message in error please notify
the sender by email, telephone or fax and destroy the message and any
copies.
Charles Lepple
2008-11-16 16:20:51 UTC
Permalink
Post by Sarah Mount
Is it actually possible to do what I'm trying to do from the Python
bindings? Presumably I need to subclass HIDInterfaceMatcher
Subclassing is the Python way, but HIDInterfaceMatcher is a C struct
wrapped by SWIG, not a full-fledged Python class.
Post by Sarah Mount
to manipulate the internal list of matched devices, but will this
have to
be done in the C library and if so where would be best to start
looking -- hid_opening.c or linux.c?
Looks like it's there in the SVN version:

http://libhid.alioth.debian.org/doc/hid__opening_8c-source.html#l00109

I almost forgot - someone finally contributed code to do just that.

You might be breaking new ground with that, though - I don't know if
that code has been tested much in Python.

My advice would be to open all of the devices sequentially in an
initialization function, and not to spawn off any new threads until
after you have opened the devices. (I don't think thread safety was
considered there.)
--
Charles Lepple
Loading...