这样吧,我讲一下我设计的思路。
STM32功能:每次windows程序发送数据过来,则保存在缓冲区内;若windows程序读取数据,则把缓冲区内的数据发送出去。
windows程序功能:执行一次功能则发送32字节数据给STM32,然后读取刚刚发送出去的32字节数据,也就是说每次发送和读取的数据应该是一样。
以下是bus hound的数据。
测试步骤:
打开windows程序,第一次发送“00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f” 32字节数据。bus hound上没有显示有读取数据,但是windows上显示读取数据都为0xcc;
第二次发送“01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20”32字节,跟着windows读取32字节“00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f”这里就不对应了。读取的32字节是第一次发送的32字节。
第三次发送“02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21”32字节,跟着windows读取32字节“ 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20”同样不对应了。读取的32字节是第二次发送的32字节。
第四次发送“03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22”32字节,跟着windows读取32字节“02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21”同样不对应了。读取的32字节是第三次发送的32字节。
bus hound数据如下:
Device - Device ID (followed by the endpoint for USB devices)
(16) Generic USB Hub
(21) STM32 USB
Phase - Phase Type
CTL USB control transfer
DI Data in
DO Data out
Data - Hex dump of the data transferred
Descr - Description of the phase
Cmd... - Position in the captured data
Device Phase Data Description Cmd.Phase.Ofs(rep)
------ ----- -------------------------------------------------- ---------------- ------------------
16.1 DI 02 . 1.1.0
16.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 2.1.0(2)
16.0 DI 01 01 01 00 .... 2.2.0
16.0 CTL 23 01 10 00 01 00 00 00 CLEAR FEATURE 4.1.0
16.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 5.1.0(2)
16.0 DI 01 01 00 00 .... 5.2.0
16.0 CTL 23 03 04 00 01 00 00 00 SET FEATURE 7.1.0
16.1 DI 02 . 8.1.0
16.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 9.1.0
16.0 DI 03 01 10 00 .... 9.2.0
16.0 CTL 23 01 14 00 01 00 00 00 CLEAR FEATURE 10.1.0
16.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 11.1.0(2)
16.0 DI 03 01 00 00 .... 11.2.0
16.0 CTL 23 03 04 00 01 00 00 00 SET FEATURE 13.1.0
16.1 DI 02 . 14.1.0
16.0 CTL a3 00 00 00 01 00 04 00 GET STATUS 15.1.0
16.0 DI 03 01 10 00 .... 15.2.0
16.0 CTL 23 01 14 00 01 00 00 00 CLEAR FEATURE 16.1.0
16.0 CTL a3 00 00 00 02 00 04 00 GET STATUS 17.1.0
16.0 DI 00 01 00 00 .... 17.2.0
16.0 CTL a3 00 00 00 03 00 04 00 GET STATUS 18.1.0
16.0 DI 00 01 00 00 .... 18.2.0
16.0 CTL a3 00 00 00 04 00 04 00 GET STATUS 19.1.0
16.0 DI 00 01 00 00 .... 19.2.0
16.0 CTL a3 00 00 00 05 00 04 00 GET STATUS 20.1.0
16.0 DI 00 01 00 00 .... 20.2.0
16.0 CTL a3 00 00 00 06 00 04 00 GET STATUS 21.1.0
16.0 DI 00 01 00 00 .... 21.2.0
16.0 CTL a3 00 00 00 07 00 04 00 GET STATUS 22.1.0
16.0 DI 00 01 00 00 .... 22.2.0
21.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 23.1.0
21.0 DI 12 01 10 01 00 00 00 40 59 58 01 00 00 02 01 02 [email=.......@YX].......@YX[/email]...... 23.2.0
03 01 .. 23.2.16
21.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 24.1.0
21.0 DI 09 02 20 00 01 01 00 a0 32 .. .....2 24.2.0
21.0 CTL 80 06 00 02 00 00 20 00 GET DESCRIPTOR 25.1.0
21.0 DI 09 02 20 00 01 01 00 a0 32 09 04 00 00 02 ff ff .. .....2....... 25.2.0
ff 04 07 05 81 02 40 00 00 07 05 02 02 40 00 00 ......@......@.. 25.2.16
21.0 CTL 80 00 00 00 00 00 02 00 GET STATUS 26.1.0
21.0 DI 03 00 .. 26.2.0
21.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 27.1.0
21.2 DO 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................ 28.1.0
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................ 28.1.16
21.2 DO 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 ................ 29.1.0
11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 ............... 29.1.16
21.1 DI 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................ 30.1.0
10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................ 30.1.16
21.2 DO 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 ................ 31.1.0
12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 .............. ! 31.1.16
21.1 DI 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 ................ 32.1.0
11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 ............... 32.1.16
21.2 DO 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 ................ 33.1.0
13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 ............. !" 33.1.16
21.1 DI 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 ................ 34.1.0
12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 .............. ! 34.1.16