Author Topic: HID device and microframes on Windows  (Read 4416 times)

cjung

  • Member
  • ***
  • Posts: 3
HID device and microframes on Windows
« on: July 20, 2020, 08:10:54 am »
Hello,

I'm trying to read reports from a HID device (Windows 10) which sends the data in microframes. The hardware is developed by the company I work for and we use the native drivers from Microsoft.
As programming language I use C++ without third party libraries.

I have some experience with HID devices and have also successfully tested my code on a "normal" HID device. There everything works and I have access to the data.

I don't really get along with the microframes. I get no data and always end up in the timeout of the WaitForSingleObject().
I had a look at the USBlyser and I see that the reports arrive at the system (they are generated by the end device independently
shipped without my involvement). I can connect to the device and also read the capabilities and properties, but not the data.

Does anyone here have any experience with this and can help me with what I am missing?
Do I possibly have to write my own driver, because the standard driver does not support this?

Thanks for your help
Chris from Germany

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID device and microframes on Windows
« Reply #1 on: July 20, 2020, 09:35:08 am »
I'm not sure what you mean by "sends the data in microframes" because all HID data arrives in frames / microframes.

My Usbhidio_vc6 is old but does use WaitForSingleObject and might be of some help:

http://www.janaxelson.com/hidpage.htm#MyExampleCode

I see no reason that you would need to write a driver to retrieve HID reports.

cjung

  • Member
  • ***
  • Posts: 3
Re: HID device and microframes on Windows
« Reply #2 on: August 12, 2020, 08:35:01 am »
Back from vacation and back to the problem.
I think I need to explain the problem in more detail.We are currently developing a HID device which should send 1024 bytes in a report.
Later we want to send 4 reports in one microframe. At the moment only one to figure out the issues.

The USB descriptor tells me the following.

        +++++++++++++++++ Device Information ++++++++++++++++++
Device Description       : USB-Eingabegerät
Device ID                : USB\VID_07C0&PID_2000\7&3188F4DA&0&2
Driver KeyName           : {745a17a0-74d3-11d0-b6fe-00a0c90f57da}\0057
Driver                   : C:\WINDOWS\System32\drivers\hidusb.sys (Version: 6.2.17134  Date: 2018-04-12)
Legacy BusType           : PNPBus
Class                    : HIDClass
Service                  : HidUsb
Enumerator               : USB
Location Info            : Port_#0002.Hub_#0006
Manufacturer Info        : (Standardsystemgeräte)
Capabilities             : Removable, SurpriseRemovalOK
Address                  : 2
Problem Code             : 0
Power State              : D0 (supported: D0, D2, D3, wake from D0, wake from D2)
Child Device 1           : HID-konformes Gerät
 Device ID               : HID\VID_07C0&PID_2000\8&C2AE1C9&1&0000
 Class                   : HIDClass

        ---------------- Connection Information ---------------
Connection Index         : 0x02
Connection Status        : 0x01 (DeviceConnected)
Current Config Value     : 0x01
Device Address           : 0x06
Is Hub                   : 0x00 (no)
Number Of Open Pipes     : 0x02 (2)
Device Bus Speed         : 0x02 (High-Speed)
Pipe0ScheduleOffset      : 0x00 (0)
Pipe1ScheduleOffset      : 0x00 (0)

        ------------- Device Qualifier Descriptor -------------
bLength                  : 0x12 (18 bytes)
bDescriptorType          : 0x01 (Device Qualifier Descriptor)
bcdUSB                   : 0x200 (USB Version 2.00)
bDeviceClass             : 0x00 (defined by the interface descriptors)
bDeviceSubClass          : 0x00
bDeviceProtocol          : 0x00
bMaxPacketSize0          : 0x40 (64 bytes)
idVendor                 : 0x07C0
idProduct                : 0x2000
bcdDevice                : 0x10
iManufacturer            : 0x01
 Language 0x0409         : "Code Mercenaries"
iProduct                 : 0x02
 Language 0x0409         : "FlickerMeter"
iSerialNumber            : 0x00
bNumConfigurations       : 0x01

        -------------- Configuration Descriptor ---------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x02 (Configuration Descriptor)
wTotalLength             : 0x0029 (41 bytes)
bNumInterfaces           : 0x01
bConfigurationValue      : 0x01
iConfiguration           : 0x04
 Language 0x0409         : "Standard Setup"
bmAttributes             : 0x80 (Bus Powered)
MaxPower                 : 0x32 (100 mA)

        ---------------- Interface Descriptor -----------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x04 (Interface Descriptor)
bInterfaceNumber         : 0x00
bAlternateSetting        : 0x00
bNumEndpoints            : 0x02
bInterfaceClass          : 0x03 (HID - Human Interface Device)
bInterfaceSubClass       : 0x00 (None)
bInterfaceProtocol       : 0x00 (None)
iInterface               : 0x05
 Language 0x0409         : "Interface0"

        ------------------- HID Descriptor --------------------
bLength                  : 0x09 (9 bytes)
bDescriptorType          : 0x21 (HID Descriptor)
bcdHID                   : 0x0111 (HID Version 1.11)
bCountryCode             : 0x00 (00 = not localized)
bNumDescriptors          : 0x01
Descriptor 1:
bDescriptorType          : 0x22 (Class=Report  Descriptor=0x02)
wDescriptorLength        : 0x0023 (35 bytes)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x81 (Direction=IN  EndpointID=1)
bmAttributes             : 0x03 (TransferType=Interrupt)
wMaxPacketSize           : 0x400 (1 transactions per microframe, max 1024 bytes)
bInterval                : 0x01 (1 ms)

        ----------------- Endpoint Descriptor -----------------
bLength                  : 0x07 (7 bytes)
bDescriptorType          : 0x05 (Endpoint Descriptor)
bEndpointAddress         : 0x01 (Direction=OUT  EndpointID=1)
bmAttributes             : 0x03 (TransferType=Interrupt)
wMaxPacketSize           : 0x40 (1 transactions per microframe, max 64 bytes)
bInterval                : 0x01 (1 ms)
--------------------------------------------------------------


Only no data arrives and I can't receive it with the example project. There the input report length of 1025 is displayed and if I want to read the data, no data arrive (Handle Error) and on the second try the tool hangs up. In my test project I already tried it with the OVERLAPPED flag and the timeout is always reached.

If we change the firmware to wMaxPacketSize : 0x40 (for endpoint 0x81 for tests), then everything works fine and the data comes through.

Now the question arises, why do the 1024 bytes arrive?
I have looked again with various USB sniffers and the data is sent over the USB (USBlyzer)

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID device and microframes on Windows
« Reply #3 on: August 17, 2020, 06:17:36 pm »
The endpoint is sending the 1024 byte report, but the host application doesn't see it unless you reduce wMaxPacketSize to 0x40?

cjung

  • Member
  • ***
  • Posts: 3
Re: HID device and microframes on Windows
« Reply #4 on: August 18, 2020, 03:48:31 am »
Do you know that you look for a bug and don't make one yourself but your colleague >:( After some research in the firmware of the device, my colleague found some hard coded values in the device firmware which did not correspond to the other values. :o
Now I can finally receive +1024 bytes and receive multiple reports in one frame (and could slap my colleague in the face very hard)
I was wondering if I am the only person in the WWW with these problems.

Thanks for the help anyway.

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: HID device and microframes on Windows
« Reply #5 on: August 19, 2020, 02:28:58 pm »
You are not the only person with these problems! Thanks for reporting back.