Windows 10 UWP HID DLL Read Input Report Fails

2

Having an issue with Windows 10 UWP C# programming to access a HID USB device.

  • I have no problem to find a device (GetDeviceSelector, DeviceInformation) and no trouble to open the device (FromIdAsync).
  • I can also send it an output report no problem (CreateOutputReport, add an array of bytes for message, SendOutputReportAsync) and the USB device reacts correctly by turning on a LED.
  • I am not able to read back the input report (GetInputReportAsync) no matter what I try including different report IDs. The device is still valid and not null when trying to do this.

I have double checked the VID, PID, Usage Page and ID. None of these are violating anything that I can find in the docs, not trying to use top level usage pages.

I have double checked the firmware in the device and its USB descriptor. The Device Manager is happy in Windows 7 or 10, no issues reported. I can access the device in Windows 7 or 10 via an interface DLL I wrote with the Windows DDK for use with Windows 7 and a test app and send/receive just fine in Windows 7 or 10. I can set LED, read back values, etc., all functions work.

I have connected a USB analyzer and the packets are there, but the GetInputReportAsync function will not return any data, just an exception "A device attached to the system is not functioning. (Exception from HRESULT: 0x8007001F)"

Using Window 10 Home, developer mode enabled. Have tried Visual Studio 2015 Community Edition and the VS 2015 Pro trial. I have tried the Windows-universal-samples-master on GitHub and the CustomHidDeviceAccess project, no luck, my device is a bit different than the one used in this demo.

Has anybody seen this before? Is there some trick or special way to do this? Is there a setting I am missing in Windows 10 or my project? Are there certain usage pages in the hex FF?? range that I cannot use with UWP? Or certain report IDs? Just wondering why I am always getting an exception when trying to get the input report via C# UWP and why my DDK DLL/app always works. Suggestions? Thx.

usb
report
uwp
hid
asked on Stack Overflow Nov 11, 2016 by user3709414

2 Answers

1

Apparently you cannot just call the GetInputReportAsync() function to read the report. Instead the only way I can get it to work is to add an event handler to my device to handle the receipt of an input report via InputReportReceived. Then after I send my output report, wait for the event handler to fire and notify of the input report data back from the device, the reply to my command. This would appear to be the only way I can get it to work on this config.

answered on Stack Overflow Nov 16, 2016 by user3709414
0

I'd like to bet it's a permissions issue. If you haven't specified permissions exactly right in the package manifest, you will be able to iterate through the devices, but you won't be able to connect. Have a read of this article http://www.idevstream.com/?p=322. It helped me to figure out exactly what I needed to put in the manifest.

Here is a working sample of one that had me stumped: https://github.com/MelbourneDeveloper/Ledger.Net/blob/master/src/Ledger.Net.UWPUnitTest/Package.appxmanifest . It works with the library https://github.com/MelbourneDeveloper/Hid.Net well.

answered on Stack Overflow Nov 25, 2018 by Christian Findlay

User contributions licensed under CC BY-SA 3.0