[libhid-discuss] libhid USB error: error sending control message: Protocol error

hatmakers hatmakers at cableone.net
Sun Mar 11 20:55:38 CET 2007



On Sun Mar 11 11:24 , Charles Lepple  sent:

>
>Actually, the usbsnoop output shows a report descriptor. I am not  
>sure why it flagged the request as invalid. Which version of usbsnoop  
>are you using?
>
The windows tool was usbutil 1.8


>
>If you are trying to stick with the HID standard, then we just need  
>to match up what Windows is doing under the hood to what libhid,  
>libusb and the Linux kernel are doing.
>
>Here's the function call that corresponds to URB #6 in your previous  
>email:
>
>http://www.ghz.cc/~clepple/libhid/doc/html/hid__preparation_8c- 
>source.html#l00058
>
>Your setup packet is as follows: 00000000: 81 06 00 22 00 00 6f 00
>
>bmRequestType = 0x81 (libhid is using the wrong constant names to  
>calculate this, but the end result is still correct)
>
>bRequest = 0x06 (libhid: USB_REQ_GET_DESCRIPTOR)
>
>wValue = 0x2200 (libhid: (USB_DT_REPORT 
>
>wIndex = 0x0000 (libhid: interface; 0 from your logs)
>
>wLength = 0x006f (libhid: hidif->hid_parser->ReportDescSize)
>
>So the only thing that I can think of is that hidif->hid_parser- 
> >ReportDescSize isn't correctly being sent. You can add a debug TRACE 
>() statement to hid_prepare_report_descriptor() to verify this.


The code will fail when it tries to prepare the hid descriptor which 
returns -71 from the usb control msg.  (see TRACE).


  TRACE: hid_init_parser(): successfully allocated memory for HIDParser strcture.
 NOTICE: hid_init_parser(): successfully initialised the HID parser for USB
Device 001/024[0].
  TRACE: hid_prepare_hid_descriptor(): initialising the HID descriptor for USB
device 001/024[0]...
  TRACE: hid_prepare_hid_descriptor(): retrieving HID descriptor for USB
device(endpoint: 80) 001/024[0]...
USB error: error sending control message: Protocol error
  TRACE: hid_prepare_hid_descriptor():
usb_control_msg(devhandle,129,6,8448,0,(char *)buffer, 24,10000) RETURNED: -71
WARNING: hid_prepare_hid_descriptor(): failed to get HID descriptor for USB
device 001/024[0]:error sending control message: Protocol error
  TRACE: hid_close(): closing USB device 001/024[0]...
  TRACE: hid_close(): closing handle of USB device 001/024[0]...
 NOTICE: hid_close(): successfully closed USB device 001/024[0].
  TRACE: hid_reset_parser(): resetting the HID parser for USB device 001/024[0]...
  TRACE: hid_close(): freeing memory allocated for HID parser...
  TRACE: hid_close(): resetting HIDInterface...
hid_force_open failed with return code 13


And since that is failing (hid_preparation.c)
it never sets the  ReportDescSize 
which is required for the hid_prepare_report_descriptor()\
right?
or is ReportDescSize able to be set someplace else?



  TRACE("usb_control_msg(devhandle,%d,%d,%d,%d,(char *)buffer, %d,%d) RETURNED:
%d", USB_ENDPOINT_IN + 1,USB_REQ_GET_DESCRIPTOR,(USB_DT_HID << 8) +
0,hidif->interface,BUFLEN,USB_TIMEOUT,len);
  /* len is -71 so it returns HERE */
  if (len < 0) {
    WARNING("failed to get HID descriptor for USB device %s:%s", hidif->id,
usb_strerror());
    return HID_RET_NOT_HID_DEVICE;
  }
  /* and never continues on to set the ReportDescSize */
  if (len < BUFLEN) {
    WARNING("HID descriptor for USB device %s is too short; "
        "expected: %d bytes; got: %d bytes.\n", hidif->id, BUFLEN, len);
    return HID_RET_HID_DESC_SHORT;
  }
  /* TODO:
   * the constants 7 and 8 should be exported.
   */
  TRACE(" *** BUFFER: %s", (char *)buffer );
  hidif->hid_parser->ReportDescSize = buffer[7] | (buffer[8] << 8);





>There are also some debugging options in the Linux kernel to see all  
>of the USB transactions at a very low level. The latest snapshots of  
>Wireshark (formerly Ethereal) can load these USB capture sessions.
>
>-- 

I have the /sys/kernel/debug/usbmon/1t 
turned on... but will have to get the latest Wireshark as my version of 
ethereal can not read the file that is created. 


James

---- Msg sent via CableONE.net MyMail - http://www.cableone.net


More information about the libhid-discuss mailing list