[libhid-discuss] libhid problems with interrupt_read/write
Thomas Maclean
tmaclean at sandbox.ca
Thu Apr 5 18:36:20 UTC 2007
Greetings:
Please excuse me if this is the wrong forum to ask about libhid usage
problems ...
I am trying to debug a problem I am having with Bruce Perens' Ion
software, which uses libhid to access a USB HID-connected home automation
controller. (See http://www.perens.com/Ion/ )
The software uses hid_interrupt_write and and
hid_interrupt_read to access the controller. I am using libhid-svn
(changelist 330) on a Centos 4 platform (a redhat clone), with
libusb-0.1.8-3.
The software compiles without problem. The first time it runs fine, the
second and subsequent times, it segfaults. (If I run it under gdb, it
segafaults every second time only.) Ion has a call to hid_interrupt_write
in the main function. If I wrap this call in a function call in another
function, it doesn't crash, but frequently returns 21. If I add unrelated
lines of code (like a new case in a switch statement that desn't do
anything!), it sometimes segfaults.
I stripped down the code to the point where it writes the command to the
HID and then fecthes any available bytes from the output HID, in a loop
every 0.5 seconds (20 times). I added calls to hid_set_debug and
hid_set_debug_stream. In my stripped-down version, it seems that write
works the first time, reads work and then the second write fails and
subsequent reads fail. hid_close works. My stripped-down version doens't
segfault (but doesn't do anything useful!)
My questions:
1) How stable is the libhid code in SVN? (i.e. is it believed robust, or
highly experimental?) No criticism implied ... I'm new around here and I
don't know.
2) Any suggestions as to why I might be seeing segfaults (in believed good
code)?
3) Any idea why me second write fails? What should I be doing differently?
Many Thanks!
Regards,
tom m.
More information about the libhid-discuss
mailing list