同样的问题,没得到回复和解决,再发一遍

 代码用的是论坛提供的参考代码,之前一直都是和单纯的键盘通信没有问题,用set_report也能正常控制NUM LOCK,CAP LOCK灯。但换成复合键盘(两个interface,两个HID报告描述符)的键盘时就无法控制灯了,键盘倒是能正常工作,而且枚举过程结束时set_report也成功点亮了NUM LOCK灯,但是仅此一次,之后再也控制不了灯了。请问参考代码是不是有需要改动的地方?

    我看论坛提供的CH376控制键盘的代码只能测试键盘按键的功能,对于set_report只是在枚举完时用了一次,之后就没有继续测试了,


若未及时回复可电话联系,025-52638373


你好:

    你的设备是复合类设备,根据你的描述是有两个接口,那么在获取描述符中应该得到两个接口号,在对键盘进行点灯操作中需要进行set_report控制传输,注意修改set_report控制帧命令。



这个复合键盘的键盘接口号是0,系统控制功能接口号是1。set_report发送的命令是0x21,0x09,0x00,0x02,0x00,0x00,0x01,0x00 看起来也没错啊,的确是发给接口0了。或者您说的修改set_report控制帧是有其他含义,我理解错了?


你好:

这样看set_report发送的应该没有错,可以将你这个符合键盘枚举中获取的描述符发来看看吗?我想确认一下这个键盘中的信息再分析原因。你可以单独邮件给我cl@wch.cn.


Connection StatusDevice connectedCurrent Configuration1SpeedLow (1.5 Mbit/s)Device Address5Number Of Open Pipes2

Device Descriptor USB Keyboard

OffsetFieldSizeValueDescription0bLength112h
1bDescriptorType101hDevice2bcdUSB20110hUSB Spec 1.14bDeviceClass100hClass info in Ifc Descriptors5bDeviceSubClass100h
6bDeviceProtocol100h
7bMaxPacketSize0108h8 bytes8idVendor21C4Fh
10idProduct20026h
12bcdDevice20110h1.1014iManufacturer101h"SIGMACHIP"15iProduct102h"USB Keyboard"16iSerialNumber100h
17bNumConfigurations101h

Configuration Descriptor 1 Bus Powered, 98 mA

OffsetFieldSizeValueDescription0bLength109h
1bDescriptorType102hConfiguration2wTotalLength2003Bh
4bNumInterfaces102h
5bConfigurationValue101h
6iConfiguration100h
7bmAttributes1A0hBus Powered, Remote Wakeup
4..0: Reserved
...00000

5: Remote Wakeup
..1.....Yes
6: Self Powered
.0......No, Bus Powered
7: Reserved (set to one)
(bus-powered for 1.0)
1.......
8bMaxPower131h98 mA

Interface Descriptor 0/0 HID, 1 Endpoint

OffsetFieldSizeValueDescription0bLength109h
1bDescriptorType104hInterface2bInterfaceNumber100h
3bAlternateSetting100h
4bNumEndpoints101h
5bInterfaceClass103hHID6bInterfaceSubClass101hBoot Interface7bInterfaceProtocol101hKeyboard8iInterface100h

HID Descriptor

OffsetFieldSizeValueDescription0bLength109h
1bDescriptorType121hHID2bcdHID20110h1.104bCountryCode100h
5bNumDescriptors101h
6bDescriptorType122hReport7wDescriptorLength20036h54 bytes

Endpoint Descriptor 81 1 In, Interrupt, 10 ms

OffsetFieldSizeValueDescription0bLength107h
1bDescriptorType105hEndpoint2bEndpointAddress181h1 In3bmAttributes103hInterrupt
1..0: Transfer Type
......11Interrupt
7..2: Reserved
000000..
4wMaxPacketSize20008h8 bytes6bInterval10Ah10 ms

Interface Descriptor 1/0 HID, 1 Endpoint

OffsetFieldSizeValueDescription0bLength109h
1bDescriptorType104hInterface2bInterfaceNumber101h
3bAlternateSetting100h
4bNumEndpoints101h
5bInterfaceClass103hHID6bInterfaceSubClass100h
7bInterfaceProtocol100h
8iInterface100h

HID Descriptor

OffsetFieldSizeValueDescription0bLength109h
1bDescriptorType121hHID2bcdHID20110h1.104bCountryCode100h
5bNumDescriptors101h
6bDescriptorType122hReport7wDescriptorLength20032h50 bytes

Endpoint Descriptor 82 2 In, Interrupt, 10 ms

OffsetFieldSizeValueDescription0bLength107h
1bDescriptorType105hEndpoint2bEndpointAddress182h2 In3bmAttributes103hInterrupt
1..0: Transfer Type
......11Interrupt
7..2: Reserved
000000..
4wMaxPacketSize20003h3 bytes6bInterval10Ah10 ms

Interface 0 HID Report Descriptor Keyboard

Item Tag (Value)Raw DataUsage Page (Generic Desktop)05 01Usage (Keyboard)09 06Collection (Application)A1 01Usage Page (LEDs)05 08Usage Minimum (Num Lock)19 01Usage Maximum (Scroll Lock)29 03Logical Minimum (0)15 00Logical Maximum (1)25 01Report Size (1)75 01Report Count (3)95 03Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)91 02Report Count (5)95 05Output (Cnst,Ary,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)91 01Usage Page (Keyboard/Keypad)05 07Usage Minimum (Keyboard Left Control)19 E0Usage Maximum (Keyboard Right GUI)29 E7Report Count (8)95 08Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02Report Size (8)75 08Report Count (1)95 01Input (Cnst,Ary,Abs)81 01Usage Minimum (Undefined)19 00Usage Maximum (Keyboard LANG2)29 91Logical Maximum (255)26 FF 00Report Count (6)95 06Input (Data,Ary,Abs)81 00End CollectionC0

Interface 1 HID Report Descriptor Consumer Control

Item Tag (Value)Raw DataUsage Page (Consumer Devices)05 0CUsage (Consumer Control)09 01Collection (Application)A1 01Report ID (1)85 01Usage Minimum (Undefined)19 00Usage Maximum (AC Format)2A 3C 02Logical Minimum (0)15 00Logical Maximum (572)26 3C 02Report Count (1)95 01Report Size (16)75 10Input (Data,Ary,Abs)81 00End CollectionC0Usage Page (Generic Desktop)05 01Usage (System Control)09 80Collection (Application)A1 01Report ID (2)85 02Usage Minimum (System Power Down)19 81Usage Maximum (System Wake Up)29 83Logical Maximum (1)25 01Report Size (1)75 01Report Count (3)95 03Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)81 02Report Count (5)95 05Input (Cnst,Ary,Abs)81 01End CollectionC0



嗨,键盘枚举的信息已发,这是一款惠普的键盘,同样的问题双飞燕的也有,因为他们都是那种两个接口两个报告描述符的键盘,因此都面临着只能使用键盘而不能控制LED灯的情况,不过在枚举结束完成后的那一下set_report倒是都把灯点亮了。


你好:

    例程中的set_report在枚举执行一次用来点灯,后面操作ch376点灯步骤其实一样,如果不是主机主动,是键盘按键提示点灯,那么set_report这条命令其实应该是在按键按下和抬起两条中断传输之间进行一次控制传输。从你描述符中看键盘接口是0,那么set_report命令的数据段就是之前的,不用改。

你可以使用抓包工具看一下电脑操作键盘点灯的数据传输过程,然后修改ch376控制键盘点灯操作。应该是软件上处理的问题。


只有登录才能回复,可以选择微信账号登录