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

Reading from a Vendor Defined HID device

Hi,

I have a vendor defined hid device with Usage Page: 0xFF00 and Usage: 0x01. I can read it through CreateFile, ReadFile function on Windows XP. However, the data rate (500 msec after 2 packets received) is far lower than the MCU transmission rate (15-byte/packet in 5ms).

Could anyone give me a hint on this situation? Thanks a lot !!!!

Danny

Parents
  • 1) Report format
    Your report descriptor is

    Usage Page    : 06 00 FF
    Usage         : 09 01
    Collection    : A1 01
    
    Report ID     : 85 01
    
    Usage         : 09 00
    Logical Min   : 15 00
    Logical Max   : 26 FF 00
    Report Size   : 75 08
    Report Count  : 95 0D
    Input         : 81 02
    
    Usage         : 09 00
    Logical Min   : 15 00
    Logical Max   : 26 FF 00
    Report Size   : 75 08
    Report Count  : 95 06
    Output        : 91 02
    
    End Collection: C0
    


    This report descriptor defines single input and single output report.
    The format of each packet is,

    Input report
     byte offset
        0     report ID (1)
      1 - 13  report body (13 bytes)
    
    Output report
     byte offset
        0     report ID (1)
      1 - 6   report body (6 bytes)
    

    Your firmware has to send 14 bytes input report packet, starting with report ID(1).
    If the packet size wouldn't be 14 bytes, or if the packet wouldn't start with 1,
    PC HID driver drops such a packet.

    If you wouldn't have any plan to extend the report descriptor to exchange another size of input or output report, you may delete the Report ID definition from your report descriptor. And then, the report ID field is deleted from the input and report packets.

    2) PC code
    hHandle = CreateFile(hDevice->DevicePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

    CreateFile opens the device synchronously (non-OVERLAPPED).
    It means, ReadFile doesn't return until it gets an input report.

    I'm not sure, what is WaitForSingleObject() waiting.
    If it would wait for ReadFile completion, it should be useless, because ReadFile returns just when it completes.

    Tsuneo

Reply
  • 1) Report format
    Your report descriptor is

    Usage Page    : 06 00 FF
    Usage         : 09 01
    Collection    : A1 01
    
    Report ID     : 85 01
    
    Usage         : 09 00
    Logical Min   : 15 00
    Logical Max   : 26 FF 00
    Report Size   : 75 08
    Report Count  : 95 0D
    Input         : 81 02
    
    Usage         : 09 00
    Logical Min   : 15 00
    Logical Max   : 26 FF 00
    Report Size   : 75 08
    Report Count  : 95 06
    Output        : 91 02
    
    End Collection: C0
    


    This report descriptor defines single input and single output report.
    The format of each packet is,

    Input report
     byte offset
        0     report ID (1)
      1 - 13  report body (13 bytes)
    
    Output report
     byte offset
        0     report ID (1)
      1 - 6   report body (6 bytes)
    

    Your firmware has to send 14 bytes input report packet, starting with report ID(1).
    If the packet size wouldn't be 14 bytes, or if the packet wouldn't start with 1,
    PC HID driver drops such a packet.

    If you wouldn't have any plan to extend the report descriptor to exchange another size of input or output report, you may delete the Report ID definition from your report descriptor. And then, the report ID field is deleted from the input and report packets.

    2) PC code
    hHandle = CreateFile(hDevice->DevicePath, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);

    CreateFile opens the device synchronously (non-OVERLAPPED).
    It means, ReadFile doesn't return until it gets an input report.

    I'm not sure, what is WaitForSingleObject() waiting.
    If it would wait for ReadFile completion, it should be useless, because ReadFile returns just when it completes.

    Tsuneo

Children