[libhid-discuss] broken pipe error

Charles Lepple clepple at ghz.cc
Tue Aug 26 11:27:46 UTC 2008


On Aug 26, 2008, at 2:54 AM, Christopher wrote:

> Now that I've got my code compiling (thanks, Marian), I've having some
> problems talking to the USB device I've got connected.
> hid_interrupt_read seems to work just fine, but I keep getting "broken
> pipe" errors when I use hid_get_input_report(). I seem to have the  
> path
> right, but I'm totally new to USB programming so I could be messing up
> something really basic.
> Thanks for any help,
> Christopher

One thing that might help is posting the hid_dump_tree() output for  
your device, and optionally the output of 'lsusb -vvv' (run as root,  
preferably after detaching the kernel usbhid driver so that the  
report descriptor shows up in the output.)

> This is the message I get:
>   TRACE: hid_get_input_report(): looking up report ID...
>   TRACE: hid_prepare_parse_path(): preparing search path of depth 3  
> for
> parse tree of USB device 001/002[0]...
>   TRACE: hid_prepare_parse_path(): search path prepared for parse tree
> of USB device 001/002[0].
>  NOTICE: hid_find_object(): found requested item.
>   TRACE: hid_get_input_report(): retrieving report ID 0x00 (length:
> 1024) from USB device 001/002[0]...

This doesn't seem to match the code below (the buffer in the code is  
16 bytes). In USB, the size of the transfer matters. Also, I don't  
know if report ID 0 is valid.

> WARNING: hid_get_input_report(): failed to retrieve report from USB
> device 001/002[0]:error sending control message: Broken pipe.

"Broken pipe" is a way for the HID device firmware to signal an error  
to the host. Unfortunately, there isn't an easy way to figure out why  
it is not happy with what it received.

> This is the function I use to call hid_get_input_report:
> hid_return ReadReport(HIDInterface *hid, int const *path, int const  
> pathlen)
> {
>     /* trys to get a 16byte report from the specified path. */
>     int const RECV_PACKET_LEN = 16;
>     char packet[RECV_PACKET_LEN];
>     int i;
>     hid_return result;
>     printf("Attempting to read from");
>     for(i = 0; i < pathlen; i++)
>     {
>         printf(" 0x%08x", path[i]);
>     }
>     printf("\n");
>     result = hid_get_input_report(hid, path, pathlen, packet,
> RECV_PACKET_LEN);
>     if (result != HID_RET_SUCCESS)
>     {
>         printf("hid_get_input_report() failed. Error code: %d\n",  
> result);
>     }
>     else
>     {
>         printf("Input report: %s\n", packet);
>     }
>     return result;
> }
>
> And then I call it like this:
>     int const PATHIN_1[PATHLEN] = { 0xffa00001, 0xffa00002,  
> 0xffa10003 };
>     ReadReport(hid, PATHIN_1, PATHLEN);
>
> PATHLEN is #defined as 3
>
> _______________________________________________
> libhid-discuss mailing list
> libhid-discuss at lists.alioth.debian.org
> http://lists.alioth.debian.org/mailman/listinfo/libhid-discuss


-- 
Charles Lepple





More information about the libhid-discuss mailing list