This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

USB HID Report ID

Hello,

I am useing an SAM7S256 controller. I want to implement a USB HID communication. I have already succeded to some degree with the Keil sample code for HID.

My problem is the Report descriptor.
I want to be able to transmit 1 to 1024 bytes from HOST to DEVICE and DEVICE to HOST. I could define a report descriptor for 1026 bytes and use 2 bytes for the length of the actual data. However I don't want to waste so much bandwidth if there is only a few bytes actual information to send.
I came up with the idea to use report IDs and to define say 17 report IDs with sizes from 64-bytes to 1026 bytes.
My problem is I don't know how to specify this so it works correctly.
Are you aware of a tool to test the descriptors in depth. The Tools I have found on the usb.org page only tell me how many errors there are in my report descriptor but not what exactly the problem is?

My descriptor so far ...

/* HID Report Descriptor */
const BYTE HID_ReportDescriptor[] = {
  HID_UsagePageVendor(0x00),
  HID_Usage(          0x01),
  HID_Collection(     HID_Application),

    // INPUT (DEVICE -> HOST)
  HID_Collection(     HID_Logical),
        HID_ReportID(     1),
        HID_Usage(        0x01),
    HID_LogicalMin(   0),
    HID_LogicalMax(   255),
    HID_ReportCount(  64),
    HID_ReportSize(   8),
    HID_Input(        HID_Data | HID_Variable | HID_Absolute),
  HID_EndCollection,


  HID_Collection(     HID_Logical),
        HID_ReportID(     2),
        HID_Usage(        0x01),
    HID_LogicalMin(   0),
    HID_LogicalMax(   255),
    HID_ReportCount(  128),
    HID_ReportSize(   8),
    HID_Input(        HID_Data | HID_Variable | HID_Absolute),
  HID_EndCollection,

        // INPUT (HOST -> DEVICE)
  HID_Collection(     HID_Logical),
        HID_ReportID(     1),
        HID_UsagePage(HID_USAGE_PAGE_GENERIC),
    HID_Usage(HID_USAGE_GENERIC_COUNTED_BUFFER),
    HID_LogicalMin(0),
    HID_LogicalMax(255),
    HID_ReportCount(64),
    HID_ReportSize(8),
    HID_Output(HID_Data | HID_Variable | HID_Absolute),
  HID_EndCollection,

 HID_Collection(     HID_Logical),
        HID_ReportID(     2),
        HID_UsagePage(HID_USAGE_PAGE_GENERIC),
    HID_Usage(HID_USAGE_GENERIC_COUNTED_BUFFER),
    HID_LogicalMin(0),
    HID_LogicalMax(255),
    HID_ReportCount(128),
    HID_ReportSize(8),
    HID_Output(HID_Data | HID_Variable | HID_Absolute),
  HID_EndCollection,

 HID_Collection(     HID_Logical),
        HID_ReportID(     3),
        HID_UsagePage(HID_USAGE_PAGE_GENERIC),
    HID_Usage(HID_USAGE_GENERIC_COUNTED_BUFFER),
    HID_LogicalMin(0),
    HID_LogicalMax(255),
    HID_ReportCount(192),
    HID_ReportSize(8),
    HID_Output(HID_Data | HID_Variable | HID_Absolute),
  HID_EndCollection,

  HID_EndCollection,
};

Parents Reply Children
  • Al Bradford: "A ZLP after sending the number of packets you desire will terminate packet transfers prior to the maximum report size."

    Per Westermark: "A short packet will also signal the end of the transfer."

    I agree with Per.
    For Input report over the interrupt IN endpoint,
    ZLP is attached to the transfer when the transfer size is just the multiple of wMaxPacketSize ( usually 64 for FS ), to show the end of transfer. That is, ZLP is attached as the short packet at the end of transfer. On other transfer size, ZLP is not required, because it is terminated by short packet.

    The exception is the report of the greatest size. For the greatest report, ZLP is not attached even when the transfer size is just the multiple of wMaxPacketSize.

    The host side doesn't know which report comes from the device next. Then, HID device driver always requests the greatest size transfer as the "expected size" to host controller. The host controller can terminate the greatest size transfer without short packet, because it matches to "expected size". But for shorter report, short packet (including ZLP) is required to terminate this "expected size" transfer.

    For Output report over interrupt OUT endpoint, no ZLP is attached even when the transfer size is just the multiple of wMaxPacketSize.



    "I don't think there is any need to have multiple Report sizes just to shorten a report from the maximum report size."

    Report descriptor declares the report format(s). HID device driver doesn't accept any report out of this format. ie. it drops such a report whose size doesn't match to any report on the report descriptor. Then, padding is required to fit to (one of) declared report size.

    Tsuneo