USB Class-Specific Requests

Set Report
Allows the host to send a report to the device.
Offset Field Size Value Description
0 bmRequestType 1 21h
4..0: Recipient …00001 Interface
6..5: Type .01….. Class
7: Direction 0……. Host-to-Device
1 bRequest 1 09h Set Report
2 wValue.LowByte 1 00h Report ID
3 wValue.HiByte 1 03h Feature Report
4 wIndex 2 0000h Interface
6 wLength 2 0040h Report Length

Get Report
Allows the host to receive a report via the control pipe.
Offset Field Size Value Description
0 bmRequestType 1 A1h
4..0: Recipient …00001 Interface
6..5: Type .01….. Class
7: Direction 1……. Device-to-Host
1 bRequest 1 01h Get Report
2 wValue.LowByte 1 00h Report ID
3 wValue.HiByte 1 03h Feature Report
4 wIndex 2 0000h Interface
6 wLength 2 0040h Report Length

1.
Class-specific requests allow the host to inquire about the capabilities and state of
a device and to set the state of output and feature items. These transactions are
done over the Default pipe and therefore follow the format of Default pipe
requests as defined in the USB Specification.

bmRequestType: Valid values are 10100001 or 00100001
7 Data transfer direction
**0 = Host to device //!!!
1 = Device to host //!!!**
6..5 Type**重点内容**
1 = Class
4..0 Recipient**重点内容**
1 = Interface
2.
The following table defines valid values of bRequest.
Value Description
0x01 GET_REPORT 1 //!!!
0x02 GET_IDLE
0x03 GET_PROTOCOL 2
0x04-0x08 Reserved
0x09 SET_REPORT //!!!
0x0A SET_IDLE
0x0B SET_PROTOCOL 2
3. Get_Report Request
The Get_Report request allows the host to receive a report via the Control pipe.
Part Description
bmRequestType 10100001
bRequest GET_REPORT
wValue Report Type and Report ID
wIndex Interface
wLength Report Length
Data Report
The wValue field specifies the Report Type in the high byte and the Report
ID in the low byte. Set Report ID to 0 (zero) if Report IDs are not used.
Report Type is specified as follows:
Value Report Type
01 Input //!!!
02 Output //!!!
03 Feature
04-FF Reserved

4.
Set_Report Request
The Set_Report request allows the host to send a report to the device, possibly
setting the state of input, output, or feature controls.
Part Description
bmRequestType 00100001
bRequest SET_REPORT
wValue Report Type and Report ID
wIndex Interface
wLength Report Length
Data Report
The meaning of the request fields for the Set_Report request is the same as for
the Get_Report request, however the data direction is reversed and the Report
Data is sent from host to device.
? A device might choose to ignore input Set_Report requests as meaningless.
Alternatively these reports could be used to reset the origin of a control (that
is, current position should report zero). The effect of sent reports will also
depend on whether the recipient controls are absolute or relative.
5. Get-Report samples

a1 01 02 01 00 00 07 00
bmRequestType:0xa1(10100001)
bRequest: GET_REPORT(0x01)
wValue: Report Type(high byte:0x02 output) and Report ID(low byte:0x01)
wIndex: Interface (0x0000)
wLength: Report Length (07 00 :7byte)>0?
Data: Report

return:
02 00 00 00 00 01 00
02 00 00 00 00 02 00 …

这里写图片描述
这里写图片描述
set_report:
CTL a1 01 03 03 00 00 00 01 GET REPORT byte[2]:report id 0x03;
CTL a1 01 02 03 00 00 00 01 GET REPORT byte[2]:report id 0x02;
byte[3]=0x03 : Feature report; wIndex = 0;wLength = 1;

21 09 02 03 00 00 07 00 00 00 00 00 00 00 00
参考:HID1_11.pdf
usb hid 上层通讯可用hidapi。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值