[libhid-discuss] timeout on interrupt read

Tarmo Johannes tarmo at otsakool.edu.ee
Fri Feb 25 17:08:38 UTC 2011


Hello,

My task is to use a digital USB-controller ( Redlab 1024LS http://www.meilhaus.de/index.php?id=26&user_produkte%5BPR%5D=90&L=1&cHash=f866b18d24 ) to read state of simple switches and use the information for sound synthesis at the end. 

After some search libhid looks very promising! Thank you for developing it!
I got it compiled (opensuse 11.3, 64bit),  test_libhid recognised the device, opened it and viewed the dump tree correctly, but I cannot read any information from the device.

I tried with two functions : hid_get_input_report() and hid_interrupt_read(), no success

1) hid_get_input_report() 

From the dump tree I assumed that the path_in should be:

<lines from  dump_tree>:
 path: 0xffa000a5.0xffa000a6; type: 0x80
.
.
path: 0xffa000a5.0xffa000a7; type: 0x90

As I understood, 0x00a6 is the input endpoint - to read data FROM device and 0x00a7 output endpoint (send data TO device)

So I formed
int const PATH_IN[2] = { 0xffa000a5, 0xffa000a6  };

Did I get it right? I did not understand how to make the PATH_IN from output of lsusb.
For any case the output of  sudo lsusb -vvv is:

 iInterface              5 EP1
        HID Device Descriptor:
          bLength                 9
          bDescriptorType        33
          bcdHID               1.10
          bCountryCode            0 Not supported
          bNumDescriptors         1
          bDescriptorType        34 Report
          wDescriptorLength      44
          Report Descriptor: (length is 44)
            Item(Global): Usage Page, data= [ 0xa0 0xff ] 65440
                            (null)
            Item(Local ): Usage, data= [ 0xa5 ] 165
                            (null)
            Item(Main  ): Collection, data= [ 0x01 ] 1
                            Application
            Item(Local ): Usage, data= [ 0xa6 ] 166
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Main  ): Input, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0xa7 ] 167
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Report Count, data= [ 0x08 ] 8
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Main  ): Output, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Local ): Usage, data= [ 0xa8 ] 168
                            (null)
            Item(Global): Logical Minimum, data= [ 0x80 ] 128
            Item(Global): Logical Maximum, data= [ 0x7f ] 127
            Item(Global): Report Count, data= [ 0x68 ] 104
            Item(Global): Report Size, data= [ 0x08 ] 8
            Item(Main  ): Feature, data= [ 0x02 ] 2
                            Data Variable Absolute No_Wrap Linear
                            Preferred_State No_Null_Position Non_Volatile Bitfield
            Item(Main  ): End Collection, data=none


The result to 

  unsigned char const RECV_PACKET_LEN = 44;
  char packet[RECV_PACKET_LEN];
  ret = hid_get_input_report(hid, PATH_IN, PATHLEN, packet, RECV_PACKET_LEN);

was:

WARNING: hid_get_input_report(): failed to retrieve report from USB device 005/002[0]:Connection timed out.


Did I guessed right that the RECV_PACKET_LEN should be the same as "Report Descriptor: (length is 44)" in lsusb output?
I tried also 8 and 1 for the RECV_PACKET_LEN but it made no difference.


2) hid_interrupt_read()

From  lsusb I read about the interrupt endpoints:

Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0008  1x 8 bytes
        bInterval              10
Device Status:     0x0001

Does Endpoit OUT means get the data out FROM device or send them out TO deivce?

Anyway, I tried both:

ret = hid_interrupt_read(hid, 0x01, packet, 8, 2000);
and
ret = hid_interrupt_read(hid, 0x81, packet, 8, 2000);

and experimented also with different packet lengths (1 and 3 instead of 8) but the result was always

WARNING: hid_interrupt_read(): timeout on interrupt read from device 005/002[0]
FAILURE calling hid_interrupt_read


I would be most happy if you could help me further!

greetings,
tarmo




More information about the libhid-discuss mailing list