Author Topic: Output report buffer length is 0 on HID vendor device.  (Read 12399 times)

wheresbicki

  • Member
  • ***
  • Posts: 3
Output report buffer length is 0 on HID vendor device.
« on: January 23, 2019, 05:02:41 pm »
I'm using the Generic HID Tester (v6.2) application to better understand HID devices.

I am trying to communicate to a touch encoder HID device (datasheet: https://www.alliedelec.com/m/d/798534efd5908c8977c561420cb32af2.pdf)

When I obtain the handle of the device based on VID: 0x1658 and PID:0x0060, I've noticed I am only able to read the 8 byte events data report as mentioned in the datasheet.

There are two other reports (input widget data report & force widget data report; both packet size of 35 bytes) that should be accessible but are not so on the Generic HID Tester. I've attached a txt file of the device properties taken from a USB Device Viewer.

Below is the output dialog from the Generic HID tester.

Code: [Select]
Name: USB Composite Device
Caption: USB Composite Device
Description: USB Composite Device
Manufacturer: (Standard USB Host Controller)
PNPDeviceID: USB\VID_1658&PID_0060\001800363037510E32323332
DeviceID: USB\VID_1658&PID_0060\001800363037510E32323332
ClassGUID: {36fc9e60-c465-11cf-8056-444553540000}
Name: USB Input Device
Caption: USB Input Device
Description: USB Input Device
Manufacturer: (Standard system devices)
PNPDeviceID: USB\VID_1658&PID_0060&MI_00\6&1445FC1C&0&0000
DeviceID: USB\VID_1658&PID_0060&MI_00\6&1445FC1C&0&0000
ClassGUID: {745a17a0-74d3-11d0-b6fe-00a0c90f57da}
Name: USB Input Device
Caption: USB Input Device
Description: USB Input Device
Manufacturer: (Standard system devices)
PNPDeviceID: USB\VID_1658&PID_0060&MI_01\6&1445FC1C&0&0001
DeviceID: USB\VID_1658&PID_0060&MI_01\6&1445FC1C&0&0001
ClassGUID: {745a17a0-74d3-11d0-b6fe-00a0c90f57da}

GetHidGuid
Result = The operation completed successfully.  GUID for system HIDs: 4d1e55b2-f16f-11cf-88cb-001111000030

CreateFile
Result = The operation completed successfully.  Returned handle: Microsoft.Win32.SafeHandles.SafeFileHandle
  HIDD_ATTRIBUTES structure filled without error.
  Structure size: 12
  Vendor ID: 1658
  Product ID: 60
  Version Number: 100
  Handle obtained to my device

  Usage: 1
  Usage Page: ff00
  Input Report Byte Length: 8
  Output Report Byte Length: 0
  Feature Report Byte Length: 0
  Number of Link Collection Nodes: 5
  Number of Input Button Caps: 1
  Number of Input Value Caps: 5
  Number of Input Data Indices: 6
  Number of Output Button Caps: 0
  Number of Output Value Caps: 0
  Number of Output Data Indices: 0
  Number of Feature Button Caps: 0
  Number of Feature Value Caps: 0
  Number of Feature Data Indices: 0

On HID PC utilities such a SimpleHIDWrite or HID Trace, I am able to switch between the multiple HID interfaces of this device and perform the missing read/write reports.  I don't see that capability on the Generic HID Tester program.  Is there a way to do this?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Output report buffer length is 0 on HID vendor device.
« Reply #1 on: January 23, 2019, 08:30:03 pm »
If the other reports are in different HID interfaces, you'll need to edit the code to select those interfaces when doing "Find the HID".

wheresbicki

  • Member
  • ***
  • Posts: 3
Re: Output report buffer length is 0 on HID vendor device.
« Reply #2 on: January 24, 2019, 09:24:36 am »
Can you point me to the HID API function that I would call to retrieve the device interface info?

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Output report buffer length is 0 on HID vendor device.
« Reply #3 on: January 27, 2019, 06:06:44 pm »
HidP_GetCaps returns report information for a HID interface.

wheresbicki

  • Member
  • ***
  • Posts: 3
Re: Output report buffer length is 0 on HID vendor device.
« Reply #4 on: January 29, 2019, 02:44:02 pm »
So I've modified the application to display enumerated devices that match my VID PID pairs.  The user can select one from that list and the FindTheHid() method uses that to match the pathName of the correct device.  So during the while loop were the FindTheHid() method checks the opened handle, I've added a condition to match the interface number in the device path name

Code: [Select]
if ((_myHid.DeviceAttributes.VendorID == _myVendorId) && (_myHid.DeviceAttributes.ProductID == _myProductId) && devicePathName[memberIndex].Contains("&mi_" + interfaceNum)){

The problem I'm running into is if I try to connect to interface 01 I get a "Fatal execution error" when the vendor ID is added to the list box.

Error from output window is below:

Code: [Select]
Device Path Name: \\?\hid#vid_1658&pid_0060&mi_01&col01#7&562b33e&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

CreateFile
Result = The operation completed successfully.  Returned handle: Microsoft.Win32.SafeHandles.SafeFileHandle
sub startPos is : 25
sub length is : 2
sub is : 01
&mi_01

  Usage: 1
  Usage Page: ff00
  Input Report Byte Length: 35
  Output Report Byte Length: 0
  Feature Report Byte Length: 0
  Number of Link Collection Nodes: 10
  Number of Input Button Caps: 0
  Number of Input Value Caps: 26
  Number of Input Data Indices: 26
  Number of Output Button Caps: 0
  Number of Output Value Caps: 0
  Number of Output Data Indices: 0
  Number of Feature Button Caps: 0
  Number of Feature Value Caps: 0
  Number of Feature Data Indices: 0
  HIDD_ATTRIBUTES structure filled without error.
  Structure size: 12
  Vendor ID: 1658
  Product ID: 60
  Version Number: 100
  Handle obtained to my device
device: \\?\hid#vid_1658&pid_0060&mi_01&col01#7&562b33e&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}

  Usage: 1
  Usage Page: ff00
  Input Report Byte Length: 35
  Output Report Byte Length: 0
  Feature Report Byte Length: 0
  Number of Link Collection Nodes: 10
  Number of Input Button Caps: 0
  Number of Input Value Caps: 26
  Number of Input Data Indices: 26
  Number of Output Button Caps: 0
  Number of Output Value Caps: 0
  Number of Output Data Indices: 0
  Number of Feature Button Caps: 0
  Number of Feature Value Caps: 0
  Number of Feature Data Indices: 0
Managed Debugging Assistant 'FatalExecutionEngineError' has detected a problem in 'C:\Users\joe.wierzbicki\Desktop\generic_hid_cs_v62\bin\Debug\GenericHid.exe'.
Additional Information: The runtime has encountered a fatal error. The address of the error was at 0x3876cb11, on thread 0x3ff4. The error code is 0xc0000005. This error may be a bug in the CLR or in the unsafe or non-verifiable portions of user code. Common sources of this bug include user marshaling errors for COM-interop or PInvoke, which may corrupt the stack.

Is there something that I'm forgetting in this loop that could be causing this Marshal error? 

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Output report buffer length is 0 on HID vendor device.
« Reply #5 on: January 31, 2019, 10:51:05 am »
It looks like you find the desired HID with interface 1 in FindTheHid, obtain a handle to it, and call HidD_GetPreparsedData, which returns data?

Is it the call to HidD_GetPreparsedData that results in the error? (Use single stepping to find out what causes the error.)

And you can successfully communicate with interface 0 on that device?