[libhid-discuss] Getting started

Marian Aldenhoevel marian.aldenhoevel at marian-aldenhoevel.de
Sat Aug 23 16:14:15 UTC 2008


Hi,

> The data I would have to send would at the core, the level of the
> device-command be ASCII 'C00', or (0x43,0x30,0x30). Prepended by 0x00, 0x03
> for the LEN, described in section 4.1.1 that would be
> 
>    (0x00,0x03,0x43,0x30,0x30)

Seems like my device specifies a number of report IDs. One per command length.
My command is 5 bytes long. So I picked Report ID 0x02 as it has a lengthof
11 Bytes. I think that would be the Path:

   const int REPORT_0x02_PATH[3] = { 0xff000001, 0xff000021, 0xff000121};

I pad my command to 11 bytes like this:

   int const cmdlen=11;
   char const cmd[11] = { 0x00,0x03,0x43,0x30,0x30,
                          0x00,0x00,0x00,0x00,0x00,0x00 };
	
And I set the report.

   hid_set_output_report(hid,REPORT_0x02_PATH,REPORT_PATH_LEN,cmd,cmdlen);

 From libhid I get:

   TRACE: hid_set_output_report(): looking up report ID...
   TRACE: hid_prepare_parse_path():  NOTICE: hid_set_output_report():
successfully sent report to USB device 001/008[0].

It says, it sent it sucessfully, but the device is not doing anything.
Documentation says it should turn off a LED. OK, maybe the Docs are wrong,
maybe the firmware did not like my command. It should give a reply anyway.

But first two observations:

1) The formatting of the output is just like I quoted. No newline after
    the hid_prepare_parse_path() and before "NOTICE". And

2) from the source code it looks like some other output has been eaten.

What could cause this?

So, my output-report has been sent. I now wanted to read input. Assuming
the same logic applies to inputs as to outputs. A 5 byte result is expected,
plus two bytes of LEN for 7 bytes. The closest report is 0x42 at 11 bytes.

So I declared:

   const int REPORT_0x42_PATH[3] = { 0xff000001, 0xff000061, 0x00000000};

   char packet[11];   	
   hid_get_input_report(hid,REPORT_0x42_PATH,REPORT_PATH_LEN,packet,11);

This provokes the following trace:

   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/008[0]...
   TRACE: hid_prepare_parse_path(): search path prepared for parse tree of USB
device 001/008[0].
   NOTICE: hid_find_object(): found requested item.
   TRACE: hid_get_input_report(): retrieving report ID 0x42 (length: 11) from
USB device 001/008[0]...
   WARNING: hid_get_input_report(): failed to retrieve report from USB device
001/008[0]:error sending control message: Broken pipe.

and hid_get_output_report() returns  20 (HID_RET_FAIL_GET_REPORT).

> The first thing I don't understand is the Report-ID. Is that an integral part
> of the PACKET I am constructing and passing to hid_set_output_report()?

I think I understood that now. The Report ID is not part of my data, but
derived from the path.

> My second question is about the PATH. I cannot make sense of the description
> in test_libhid.c under "How to write to and read from a device". Can someone
> please take a look at my lsusb -vvv output (link above) and explain again
> for dummies?

I think I figured that out, too. After a day of re-reading that comment, but
better late than never. The path-arrays I arrived at seem to work.

Ciao, MM




More information about the libhid-discuss mailing list