[libhid-discuss] Strange behaviour of LIBHID in Linux

Günther Sohler guenther.sohler at scitronix.com
Tue Apr 26 07:52:52 UTC 2011


Hello Group,

As I am a HID beginner, please excuse myself if I do absolutely stupid things and rather help me :)


I have  built a LIBHID Hardware device and I'd like to send and receive reports from it.
It generally works but its quite circular and definitely not the way as it should be.

to send reports, I do:

ret = hid_set_output_report(handle[ind], locptr, loclen, temp, buflen);
...
ret = hid_interrupt_read(handle[ind], 0x01, temp, buflen, 1000); // sync write

even tough the second command returns an error- without it the information is not transmitted

to receive reports, I do

ret = hid_interrupt_read(handle[ind], 0x01, temp, buflen, 1000); // sync read
...
ret = hid_get_input_report(handle[ind], locptr, loclen, temp, buflen);

without the "sync read" line, hid_get_input_report does not deliver up-to-date data

I'd like to get rid of the the "sync" lines but It does not work without.
Can anybody tell me, whats wrong ?

===
My HID Slave device has only one Interrupt IN Endpoint. Is this correct ?This is an template example from a HID Keyboard,
which can send(led indicators) and receive(key buttons) data.
This is the code which creates the usb config descriptor:

const hcc_u8 config_descriptor[] = {
       USB_FILL_CFG_DESC(9+3+9+9+7, 1, 1, 4, CFGD_ATTR_SELF_PWR, 0),
        USB_FILL_OTG_DESC(1, 1),
        USB_FILL_IFC_DESC(CUSTOM_IFC_INDEX, 0, 1, 0x3, 0x0, 0x0, 5), /* HID, none, none */
        USB_FILL_HID_DESC(9, 0x0100, 0x0, 1, 0x22, sizeof(report_descriptor)),
        USB_FILL_EP_DESC(0x1, 1, 0x3, 8, 0x20),
};

my report descriptor looks like

const hcc_u8 report_descriptor[39] = {
        0x06, 0x02,0xff,                /* USAGE_PAGE  */
        0x09, 0x01,                    /* USAGE  */
        0xa1, 0x01,                    /* COLLECTION  */
        
        0x06, 0x02,0xff,                /* USAGE_PAGE  */
        0x09, 0x01,                    /*   USAGE  */

        0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
        0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
        0x75, 0x01,                    //   REPORT_SIZE (1)
        0x95, 0x08,                    //   REPORT_COUNT (8)
        0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)


        0x05, 0x02,                    /*     USAGE_PAGE  */
        0x19, 0x01,                    /*     USAGE_MINIMUM (Sensor 1) */
        0x29, 0x08,                    /*     USAGE_MAXIMUM (Sensor 8) */
        0x15, 0x00,                    /*     LOGICAL_MINIMUM (0) */
        0x25, 0xFF,                    /*     LOGICAL_MAXIMUM (255) */
        
        0x95, 0x08,                    /*     REPORT_SIZE (8) */
        0x75, 0x08,                    /*     REPORT_COUNT (8) */
        0x81, 0x02,                    /*     INPUT (Data,Var,Rel) */
        
        0xc0                           /* END_COLLECTION */
};

Any Hints are appreciated
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/libhid-discuss/attachments/20110426/83420ad6/attachment.htm>


More information about the libhid-discuss mailing list