This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

USB HID IN report failure

Background

I am interested in sending/receiving large HID reports. Here is a working descriptor that has been verified in another application on another processor:

Item Tag (Value) Raw Data 
Usage Page (Generic Desktop) 05 01  
Usage (Undefined)            09 00  
Collection (Application)     A1 01  
    Logical Minimum (0)      15 00  
    Logical Maximum (255) 26 FF 00  
    Report Size (8)               75 08  
    Report Count (63)          95 3F  
    Usage (Undefined)        09 00  
    Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit) 81 02  
    Report Size (8)             75 08  
    Report Count (63)        95 3F  
    Usage (Undefined)       09 00  
    Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit) 91 02  
End Collection C0  

Originally report count was 64 but just to be safe I have reduced it. My endpoints look like this:

I will be communicating on the PC side using ReadFile and WriteFile which (according to Jan Axelson's book) use Interrupt IN to transfer data as opposed to "Control with Get Report request"
Microsoft warns against using HidD_GetInputReport because that bypasses some buffering or whatever.


The Issue

I can send output reports just fine as far as I can tell. I send input reports via button press.

if (keys & HAL_KEY_SW_1)
{
  while (!hidSendHidInReport(h, USB_HID_KBD_EP, 63));
}

where h is a pointer. I seem to have developed a partial solution to this problem while writing this post, so hopefully if someone else runs into a similar issue they will be helped by this post.

  • I seem to have solved this problem for the time being. I beleive the issue may have been that I was not sending a full IN report.

    The IN report length was defined to be 63 bytes, the endpoint max packet size 64 bytes, and I was sending less than 63 bytes for each report. I increased the size passed to hidSendHidInReport and am now able to read reports.

    The reports are read using interrupt transfers and reports are sent using control transfers. This seems to be acceptable for my application and I suppose fixed packet sizes are not too harmful either. If there are any precautions or warnings you may have for me, please share them.

    Thank you.

  • Hi,

    I am not sure what deice you are using for sending the HID reports. But as per HID Spec Section 2.5.1, the HID reports should be less than the MTU -3 Bytes size. 

    For all Report characteristics containing Input Report data, a Client Characteristic Configuration descriptor shall exist and, if the Client Characteristic Configuration descriptor is configured for notifications, the HID Device shall notify the HID Host when the characteristic value changes, using the GATT Notification sub-procedure. This procedure maps to Data Input in USB HID [2].

    Note: Notification of characteristic values can contain at most [ATT_MTU-3] bytes of data by definition (see [3], Volume 3, Part F, Section 3.4.7.1). Data beyond [ATT_MTU-3] bytes long is not included in a notification, and must instead be read using the GATT Read Long Characteristic Value sub-procedure. The possibility that data to be notified in a Report characteristic value could change before the HID Host completed an outstanding Read Long Characteristic Value sub-procedure, and therefore be lost, exists. For this reason it is strongly recommended that HID Devices support an ATT_MTU large enough to transfer their largest possible Report characteristic value in a single transaction.

    Please ensure that this is taken care of by your HID peripheral device and HID Host

    Regards,
    Arun