PORTS Forum
Ports and Interfaces => USB => Topic started by: kberisso on October 27, 2014, 09:59:55 pm
-
I was hoping to get some help (and maybe some education) on talking to USB HID devices with the new Win 8.1 System.Devices.HumanInterfaceDevice namespace. I am trying to connect to a device via the "endpoints" instead of via reports... first, what is the difference. I have been looking and can't quite make out what the differences. And more importantly, how do I communicate to the device? I have used your sample code in the past to talk to the device, and am now trying to upgrade the apps to the newer Windows 8.1 Store Apps.
Thanks
Kevin
-
The documentation here:
http://msdn.microsoft.com/en-us/library/windows/apps/bg182882.aspx#one
says:
Apps retrieve data from a HID device by using input reports.
and gives this example:
var inputReport = await DeviceList.Current.CurrentDevice.GetInputReportAsync(SuperMutt.ReadWriteBuffer.ReportId);
Can you give an example of what you're attempting?
-
Thanks for the quick reply.
I have been to the site and can "see" the USB device (it is an RFID reader that is set up as a USB HID device with the following info:
Device Descriptor:
bcdUSB: 0x0110
bDeviceClass: 0xFF
bDeviceSubClass: 0x00
bDeviceProtocol: 0xFF
bMaxPacketSize0: 0x08 (8)
bcdDevice: 0x0001
bNumConfigurations: 0x01
ConnectionStatus: DeviceConnected
Current Config Value: 0x01
Device Bus Speed: Full
Device Address: 0x04
Open Pipes: 2
Endpoint Descriptor:
bEndpointAddress: 0x01 OUT
Transfer Type: Interrupt
wMaxPacketSize: 0x0040 (64)
bInterval: 0x01
Endpoint Descriptor:
bEndpointAddress: 0x82 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0040 (64)
bInterval: 0x01
Configuration Descriptor:
wTotalLength: 0x0029
bNumInterfaces: 0x01
bConfigurationValue: 0x01
iConfiguration: 0x00
bmAttributes: 0xC0 (Bus Powered Self Powered )
MaxPower: 0xFA (500 Ma)
Interface Descriptor:
bInterfaceNumber: 0x00
bAlternateSetting: 0x00
bNumEndpoints: 0x02
bInterfaceClass: 0x03 (HID)
bInterfaceSubClass: 0x00
bInterfaceProtocol: 0x00
iInterface: 0x00
HID Descriptor:
bcdHID: 0x0111
bCountryCode: 0x00
bNumDescriptors: 0x01
bDescriptorType: 0x22
wDescriptorLength: 0x0062
Endpoint Descriptor:
bEndpointAddress: 0x01 OUT
Transfer Type: Interrupt
wMaxPacketSize: 0x0040 (64)
bInterval: 0x01
Endpoint Descriptor:
bEndpointAddress: 0x82 IN
Transfer Type: Interrupt
wMaxPacketSize: 0x0040 (64)
bInterval: 0x01
I am trying to send it a command (4349544DFF130000000000000000) that is 16 bytes long.
What I don't get (and never really understood even with the WinXP/7 version of my program) is how the endpoints relate to the reports. I am assuming that the "In" endpoint is the input report and the "Out" endpoint is the output report, but if that is the case, I can't seem to get my command string into the report
I tried:
var output = myDevice.CreateOutputReport();
var dataWriter = new DataWriter();
dataWriter.WriteBytes(myData);
dataWriter.DetachBuffer();
uint result = await myDevice.SendOutputReportAsync(output);
but always get a Access Denied error when I hit the last line (where I send the report). I know that I have a good device and have confirmed that myDevice is valid (or at least I can see a VID/PID and other related info).
Thanks
Kevin