简体   繁体   English

Windows USB HID报告长度

[英]Windows USB HID Report Length

I am developing a USB HID device using an STMicro microcontroller. 我正在使用STMicro微控制器开发USB HID设备。 I started with STMicro's HID example which works fine. 我从STMicro的HID示例开始,该示例运行良好。 I am using C++ on Windows 7 64-bit for the PC side. 我在Windows 7 64位PC端使用C ++。 I have an application that works with my device. 我有一个适用于我的设备的应用程序。 There is one thing I can't figure out, however. 但是,有一件事我不知道。

The example firmware only allowed sending and receiving 2 bytes at a time, which is determined by a HIDP_CAPS.OutputReportByteLength and InputReportByteLength. 示例固件仅一次允许发送和接收2个字节,这由HIDP_CAPS.OutputReportByteLength和InputReportByteLength确定。 I would like to send more data than this at once, but I can't figure out how to increase the report lengths. 我想一次发送更多的数据,但是我不知道如何增加报告的长度。 I successfully changed the endpoint wMaxPacketSize, the VID and PID, and a few other things, but I can't figure out how Windows is calculating the in and out report lengths. 我成功地更改了端点wMaxPacketSize,VID和PID以及其他一些内容,但是我无法弄清楚Windows如何计算输入和输出报告的长度。 There doesn't seem to be any fields in my report or device descriptions that indicate this length, but I can't imagine where else it might be coming from. 我的报告或设备描述中似乎没有任何字段指示该长度,但是我无法想象它可能来自何处。

Can anyone tell me how Windows determines the HIDP_CAPS.OutputReportByteLength and HIDP_CAPS.InputReportByteLength? 谁能告诉我Windows如何确定HIDP_CAPS.OutputReportByteLength和HIDP_CAPS.InputReportByteLength?

How can I increase these lengths? 如何增加这些长度?

I figured it out. 我想到了。 I thought I would post here in case anyone else needs to know. 我以为我会在这里发布,以防其他人需要知道。 I'm not entirely sure I really understand it all, so if I made a mistake, someone please correct me. 我不能完全确定我是否真的了解这一切,所以如果我犯了一个错误,请有人纠正我。

I had to change the report description in my firmware. 我必须在固件中更改报告说明。 I had several usages. 我有几种用法。 Windows gets the report description and figures out which usage requires the longest length and uses that length. Windows获取报告说明,并找出哪种用法需要最长的长度并使用该长度。 On one of my input reports I made the following changes (the input report is just an array of bytes in firmware): 在一个输入报告中,我做了以下更改(输入报告只是固件中的一个字节数组):

0x27, 0xFF, 0xFF, 0xFF, 0xFF, //Logical maximum is 4 bytes long, and has a value of 0xFFFFFFFF 0x95, 0x01, //There is one report 0x75, 0x20, //There are 32 bits per report

I did something similar for the output, but there is no report number field (0x95). 我对输出做了类似的操作,但是没有报告编号字段(0x95)。

Windows now tells me I can send and receive 5 bytes, which I believe means the end point plus report number times report size. Windows现在告诉我可以发送和接收5个字节,我相信这意味着端点加报告号乘以报告大小。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM