374获取设备描述符有问题

UINT8 GetDeviceDescr( PUINT8 buf ) // 获取设备描述符 { UINT8 s, len; UsbDevEndpSize = DEFAULT_ENDP0_SIZE; s = HostCtrlTransfer374( SetupGetDevDescr, buf, &len ); // 执行控制传输 if ( s == USB_INT_SUCCESS ) { UsbDevEndpSize =((PUSB_DEV_DESCR)buf )-> bMaxPacketSize0; // 端点0最大包长度,这是简化处理,正常应该先获取前8字节后立即更新UsbDevEndpSize再继续 if ( len < ( (PUSB_SETUP_REQ)SetupGetDevDescr ) -> wLengthL ) s = USB_INT_BUF_OVER; // 描述符长度错误 } return( s ); }

请教一下,现有一个产品不能 获取设备描述符,用了上面的程式 下面的看了很长时间,不是太理解: // 端点0最大包长度,这是简化处理,正常应该先获取前8字节后立即更新UsbDevEndpSize再继续

这个没有简化处理的应怎么写,给一个例程,谢谢!

这个简化处理的获取设备描述符的程序是可以获取到描述符的,没简化的只是需要先更新端点大小再获取剩余的描述符。你是获取什么设备的描述符?返回错误代码是什么?


键盘,大多的键盘都可以,就这个不行(用的芯片不同),返回的为32(0x20);


那你看一下这个键盘和其他键盘有什么区别?返回0x20是应答超时,说明设备没有给主机应答或者应答错误


Bus Hound 3.02 capture. Complements of www.perisoft.net

ng

Dev - Device ID Time - Elapsed time since the start of the previous Phase Phase - ADDR= 1394 transfer address LOCK= 1394 lock transaction CDB = Command block NSTS= NT status CTL = USB control packet RSET= bus reset DI = Data In RSTS= I/O Request Status DO = Data Out SNS = SCSI Sense Data IDE = IDE task file command SSTS= SCSI Request Block Status ISOC= Isochronous Transfer USTS= USB status

(10) USB Root Hub (11) Intel(R) N10/ICH7 Family USB Universal Host Controller - 27CA (18) USB Composite Device (19) USB 人体学输入设备

Dev Phase Data Info Time Cmd.Phase.Ofs --- ----- ----------------------------------------------------- ---------------- ----- ------------------ 18 DI 00 00 00 00 - a0 66 8e f7 .....f.. 0us 1.1.0 18 USTS 00 70 00 c0 error 2us 1.2.0 19 DI 00 00 00 00 - a0 66 8e f7 .....f.. 1us 2.1.0 19 USTS 00 70 00 c0 error 1us 2.2.0 18 USTS 00 70 00 c0 error 2.1sc 3.1.0 18 USTS 00 70 00 c0 error 512ms 4.1.0 19 USTS 00 70 00 c0 error 3us 5.1.0 18 CTL 80 06 00 01 - 00 00 12 00 GET DESCRIPTR 853ms 6.1.0 18 DI 12 01 10 01 - 00 00 00 08 - 2c 1a 21 0c - 10 01 01 02 ........,.!..... 5.9ms 6.2.0 00 01 .. 6.2.16 18 CTL 80 06 00 02 - 00 00 09 00 GET DESCRIPTR 10us 7.1.0 18 DI 09 02 3b 00 - 02 01 00 a0 - 32 ..;.....2 4.9ms 7.2.0 18 CTL 80 06 00 02 - 00 00 3b 00 GET DESCRIPTR 7us 8.1.0 18 DI 09 02 3b 00 - 02 01 00 a0 - 32 09 04 00 - 00 01 03 01 ..;.....2....... 10ms 8.2.0 01 00 09 21 - 10 01 00 01 - 22 36 00 07 - 05 81 03 08 ...!...."6...... 8.2.16 00 0a 09 04 - 01 00 01 03 - 01 02 00 09 - 21 10 01 00 ............!... 8.2.32 01 22 6c 00 - 07 05 82 03 - 05 00 0a ."l........ 8.2.48 18 CTL 00 09 01 00 - 00 00 00 00 SET CONFIG 16us 9.1.0 18 USTS 00 03 00 80 parm invalid 37ms 10.1.0 18 CTL 80 06 00 03 - 00 00 ff 00 GET DESCRIPTR 376us 11.1.0 18 DI 04 03 09 04 .... 4.8ms 11.2.0 18 CTL 80 06 02 03 - 09 04 ff 00 GET DESCRIPTR 13us 12.1.0 18 DI 1a 03 55 00 - 53 00 42 00 - 20 00 4b 00 - 65 00 79 00 ..U.S.B. .K.e.y. 7.9ms 12.2.0 62 00 6f 00 - 61 00 72 00 - 64 00 b.o.a.r.d. 12.2.16 18 CTL 80 06 00 03 - 00 00 ff 00 GET DESCRIPTR 23us 13.1.0 18 DI 04 03 09 04 .... 4.9ms 13.2.0 18 CTL 80 06 02 03 - 09 04 ff 00 GET DESCRIPTR 11us 14.1.0 18 DI 1a 03 55 00 - 53 00 42 00 - 20 00 4b 00 - 65 00 79 00 ..U.S.B. .K.e.y. 7.9ms 14.2.0 62 00 6f 00 - 61 00 72 00 - 64 00 b.o.a.r.d. 14.2.16 18 CTL 80 06 00 03 - 00 00 ff 00 GET DESCRIPTR 1.3ms 15.1.0 18 DI 04 03 09 04 .... 4.6ms 15.2.0 18 CTL 80 06 02 03 - 09 04 ff 00 GET DESCRIPTR 13us 16.1.0 18 DI 1a 03 55 00 - 53 00 42 00 - 20 00 4b 00 - 65 00 79 00 ..U.S.B. .K.e.y. 7.9ms 16.2.0 62 00 6f 00 - 61 00 72 00 - 64 00 b.o.a.r.d. 16.2.16 18 CTL 80 06 00 03 - 00 00 ff 00 GET DESCRIPTR 24us 17.1.0 18 DI 04 03 09 04 .... 4.9ms 17.2.0 18 CTL 80 06 02 03 - 09 04 ff 00 GET DESCRIPTR 10us 18.1.0 18 DI 1a 03 55 00 - 53 00 42 00 - 20 00 4b 00 - 65 00 79 00 ..U.S.B. .K.e.y. 7.9ms 18.2.0 62 00 6f 00 - 61 00 72 00 - 64 00 b.o.a.r.d. 18.2.16 19 CTL 80 06 00 01 - 00 00 12 00 GET DESCRIPTR 1.6ms 19.1.0 19 DO 12 01 10 01 - 00 00 00 08 - 2c 1a 21 0c - 10 01 01 02 ........,.!..... 3us 19.2.0 00 01 .. 19.2.16 19 CTL 80 06 00 02 - 00 00 09 00 GET DESCRIPTR 3us 20.1.0 19 DO 09 02 22 00 - 01 01 00 a0 - 32 ..".....2 2us 20.2.0 19 CTL 80 06 00 02 - 00 00 22 00 GET DESCRIPTR 2us 21.1.0 19 DO 09 02 22 00 - 01 01 00 a0 - 32 09 04 00 - 00 01 03 01 ..".....2....... 1us 21.2.0 01 00 09 21 - 10 01 00 01 - 22 36 00 07 - 05 81 03 08 ...!...."6...... 21.2.16 00 0a .. 21.2.32 19 CTL 00 09 01 00 - 00 00 00 00 SET CONFIG 3us 22.1.0 19 CTL 21 0a 00 00 - 00 00 00 00 CLASS 3us 23.1.0 18 CTL 21 0a 00 00 - 00 00 00 00 CLASS 2us 24.1.0 19 CTL 80 06 00 22 - 00 00 76 00 GET DESCRIPTR 2.3ms 25.1.0 18 CTL 80 06 00 22 - 00 00 76 00 GET DESCRIPTR 12us 26.1.0 18 DI 05 01 09 06 - a1 01 05 08 - 19 01 29 03 - 15 00 25 01 ..........)...%. 10ms 26.2.0 75 01 95 03 - 91 02 95 05 - 91 01 05 07 - 19 e0 29 e7 u.............). 26.2.16 95 08 81 02 - 75 08 95 01 - 81 01 19 00 - 29 91 26 ff ....u.......).&. 26.2.32 00 95 06 81 - 00 c0 ...... 26.2.48 19 DI 05 01 09 06 - a1 01 05 08 - 19 01 29 03 - 15 00 25 01 ..........)...%. 3us 25.2.0 75 01 95 03 - 91 02 95 05 - 91 01 05 07 - 19 e0 29 e7 u.............). 25.2.16 95 08 81 02 - 75 08 95 01 - 81 01 19 00 - 29 91 26 ff ....u.......).&. 25.2.32 00 95 06 81 - 00 c0 ...... 25.2.48 18 CTL 21 0a 00 00 - 01 00 00 00 CLASS 2.1ms 27.1.0 18 CTL 80 06 00 22 - 01 00 ac 00 GET DESCRIPTR 2.8ms 28.1.0 18 DI 05 01 09 02 - a1 01 85 03 - 09 01 a1 00 - 05 09 19 01 ................ 17ms 28.2.0 29 03 15 00 - 25 01 95 03 - 75 01 81 02 - 95 01 75 05 )...%...u.....u. 28.2.16 81 01 05 01 - 09 30 09 31 - 09 38 15 81 - 25 7f 75 08 .....0.1.8..%.u. 28.2.32 95 03 81 06 - c0 c0 05 01 - 09 80 a1 01 - 85 02 19 81 ................ 28.2.48 29 83 15 00 - 25 01 75 01 - 95 03 81 02 - 75 01 95 05 )...%.u.....u... 28.2.64 81 01 c0 05 - 0c 09 01 a1 - 01 85 01 19 - 00 2a 3c 02 .............*<. 28.2.80 15 00 26 3c - 02 95 01 75 - 10 81 00 c0 ..&<...u.... 28.2.96 19 CTL 21 09 00 02 - 00 00 01 00 CLASS 1.0sc 29.1.0 18 CTL 21 09 00 02 - 00 00 01 00 CLASS 9us 30.1.0 18 DO 01 . 3.4ms 30.2.0 19 DO 01 . 3us 29.2.0 18 DI 00 00 00 00 - 00 00 00 00 ........ 7.9ms 31.1.0 19 DI 00 00 00 00 - 00 00 00 00 ........ 2us 32.1.0


Bus Hound 3.02 capture. Complements of www.perisoft.net

ok

Dev - Device ID Time - Elapsed time since the start of the previous Phase Phase - ADDR= 1394 transfer address LOCK= 1394 lock transaction CDB = Command block NSTS= NT status CTL = USB control packet RSET= bus reset DI = Data In RSTS= I/O Request Status DO = Data Out SNS = SCSI Sense Data IDE = IDE task file command SSTS= SCSI Request Block Status ISOC= Isochronous Transfer USTS= USB status

(10) USB Root Hub [4KB/Sec] (11) Intel(R) N10/ICH7 Family USB Universal Host Controller - 27CA (18) USB Composite Device (19) USB 人体学输入设备

Dev Phase Data Info Time Cmd.Phase.Ofs --- ----- ----------------------------------------------------- ---------------- ----- ------------------ 10 USTS 00 70 00 c0 error 0us 1.1.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 172ms 2.1.0 10 DI 01 03 01 00 .... 20us 2.2.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 10us 3.1.0 10 DI 01 03 01 00 .... 24us 3.2.0 10 CTL 23 01 10 00 - 02 00 00 00 CLASS 13us 4.1.0 10 CTL a3 00 00 00 - 01 00 04 00 CLASS 148us 5.1.0 10 DI 08 00 00 00 .... 11us 5.2.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 7us 6.1.0 10 DI 01 03 00 00 .... 10us 6.2.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 115ms 7.1.0 10 DI 01 03 00 00 .... 32us 7.2.0 10 CTL 23 03 04 00 - 02 00 00 00 CLASS 14us 8.1.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 26ms 9.1.0 10 DI 03 03 10 00 .... 25us 9.2.0 10 CTL 23 01 14 00 - 02 00 00 00 CLASS 2us 10.1.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 26ms 11.1.0 10 DI 03 03 00 00 .... 31us 11.2.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 24ms 12.1.0 10 DI 03 03 00 00 .... 30us 12.2.0 10 CTL 23 03 04 00 - 02 00 00 00 CLASS 14us 13.1.0 10 CTL a3 00 00 00 - 02 00 04 00 CLASS 26ms 14.1.0 10 DI 03 03 10 00 .... 25us 14.2.0 10 CTL 23 01 14 00 - 02 00 00 00 CLASS 2us 15.1.0 10 CTL 80 06 00 02 - 00 00 ff 00 GET DESCRIPTR 83ms 16.1.0 10 DI 09 02 22 00 - 01 01 00 a0 - 32 09 04 00 - 00 01 03 01 ..".....2....... 8.8ms 16.2.0 01 00 09 21 - 10 01 00 01 - 22 41 00 07 - 05 81 03 08 ...!...."A...... 16.2.16 00 0a .. 16.2.32 10 CTL 80 06 00 03 - 00 00 ff 00 GET DESCRIPTR 135us 17.1.0 10 DI 04 03 09 04 .... 4.8ms 17.2.0 10 CTL 80 06 02 03 - 09 04 ff 00 GET DESCRIPTR 29us 18.1.0 10 DI 2e 03 44 00 - 65 00 6c 00 - 6c 00 20 00 - 51 00 75 00 ..D.e.l.l. .Q.u. 9.8ms 18.2.0 69 00 65 00 - 74 00 4b 00 - 65 00 79 00 - 20 00 4b 00 i.e.t.K.e.y. .K. 18.2.16 65 00 79 00 - 62 00 6f 00 - 61 00 72 00 - 64 00 e.y.b.o.a.r.d. 18.2.32 10 CTL 80 06 00 03 - 00 00 ff 00 GET DESCRIPTR 27us 19.1.0 10 DI 04 03 09 04 .... 4.9ms 19.2.0 10 CTL 80 06 02 03 - 09 04 ff 00 GET DESCRIPTR 19us 20.1.0 10 DI 2e 03 44 00 - 65 00 6c 00 - 6c 00 20 00 - 51 00 75 00 ..D.e.l.l. .Q.u. 9.9ms 20.2.0 69 00 65 00 - 74 00 4b 00 - 65 00 79 00 - 20 00 4b 00 i.e.t.K.e.y. .K. 20.2.16 65 00 79 00 - 62 00 6f 00 - 61 00 72 00 - 64 00 e.y.b.o.a.r.d. 20.2.32 10 CTL 80 06 00 01 - 00 00 12 00 GET DESCRIPTR 3.1ms 21.1.0 10 DI 12 01 10 01 - 00 00 00 08 - 3c 41 06 21 - 01 01 01 02 ........ 00 01 .. 21.2.16 10 CTL 80 06 00 02 - 00 00 09 00 GET DESCRIPTR 20us 22.1.0 10 DI 09 02 22 00 - 01 01 00 a0 - 32 ..".....2 4.9ms 22.2.0 10 CTL 80 06 00 02 - 00 00 22 00 GET DESCRIPTR 16us 23.1.0 10 DI 09 02 22 00 - 01 01 00 a0 - 32 09 04 00 - 00 01 03 01 ..".....2....... 7.9ms 23.2.0 01 00 09 21 - 10 01 00 01 - 22 41 00 07 - 05 81 03 08 ...!...."A...... 23.2.16 00 0a .. 23.2.32 10 CTL 00 09 01 00 - 00 00 00 00 SET CONFIG 19us 24.1.0 10 CTL 21 0a 00 00 - 00 00 00 00 CLASS 20ms 25.1.0 10 CTL 80 06 00 22 - 00 00 81 00 GET DESCRIPTR 2.5ms 26.1.0 10 DI 05 01 09 06 - a1 01 05 07 - 19 e0 29 e7 - 15 00 25 01 ..........)...%. 12ms 26.2.0 75 01 95 08 - 81 02 95 01 - 75 08 81 01 - 95 03 75 01 u.......u.....u. 26.2.16 05 08 19 01 - 29 03 91 02 - 95 05 75 01 - 91 01 95 06 ....).....u..... 26.2.32 75 08 15 00 - 26 ff 00 05 - 07 19 00 2a - ff 00 81 00 u...&......*.... 26.2.48 c0 . 26.2.64 10 CTL 21 09 00 02 - 00 00 01 00 CLASS 1.0sc 27.1.0 10 DO 01 . 3.4ms 27.2.0


第一个为不行的,取了两次设备符, 18 CTL 80 06 00 01 - 00 00 12 00 GET DESCRIPTR 853ms 6.1.0 18 DI 12 01 10 01 - 00 00 00 08 - 2c 1a 21 0c - 10 01 01 02 ........,.!..... 5.9ms 6.2.0 00 01

19 CTL 80 06 00 01 - 00 00 12 00 GET DESCRIPTR 1.6ms 19.1.0 19 DO 12 01 10 01 - 00 00 00 08 - 2c 1a 21 0c - 10 01 01 02 ........,.!..... 3us 19.2.0 00 01

第二个为OK的,只取了一次 10 CTL 80 06 00 01 - 00 00 12 00 GET DESCRIPTR 3.1ms 21.1.0 10 DI 12 01 10 01 - 00 00 00 08 - 3c 41 06 21 - 01 01 01 02 ........ 00 01


看了你第一个键盘获取的描述符,第二次获取的时候数据方向D0(Data Out)这是不对的,你的设备接到电脑上能用吗?还有你二楼说的 就这个不行(用的芯片不同)是什么意思?


接到电脑上可以用,没有问题 还有你二楼说的 就这个不行(用的芯片不同)是什么意思?-------------两个键盘用的芯片不同,其他的芯片没有问题,只有这个VID不同的芯片不能取得描述符。


你把你的程序打包发送到我的邮箱。


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