我有一個(gè)USB設(shè)備,在WINDOWS XP下被識(shí)別為USB鍵盤(pán),然后我用51和CH375芯片做了一個(gè)USB主機(jī),目的是處理從此設(shè)備得到的數(shù)據(jù)(此設(shè)備為讀碼器,將讀碼器插到PC后,任意打開(kāi)一個(gè)文檔編輯器,然后掃描一個(gè)條碼,就會(huì)在文檔編輯器里面自動(dòng)輸入條形碼的值最后帶個(gè)回車)。 但是問(wèn)題是,我做的這個(gè)主機(jī)可以正確地識(shí)別從USB鍵盤(pán)得到的數(shù)據(jù),卻不能正確得到從此設(shè)備發(fā)來(lái)的數(shù)據(jù),不知道問(wèn)題出在哪里?我是用驅(qū)動(dòng)USB鍵盤(pán)的程序驅(qū)動(dòng)此USB設(shè)備的。
我的USB鍵盤(pán)配置如下: 12 01 10 01 00 00 00 08 3c 41 03 20 00 02 01 02 00 01 config 09 02 22 00 01 01 04 a0 23 config 2 09 02 22 00 01 01 04 a0 23 09 04 00 00 01 03 01 01 05 09 21 10 01 00 01 22 41 00 07 05 81 03 08 00 18 set idle report 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 75 01 95 08 81 02 95 01 75 08 81 01 95 03 75 01 05 08 19 01 29 03 91 02 95 01 75 05 91 01 95 06 75 08 15 00 26 ff 00 05 07 19 00 2a ff 00 81 00 c0 set report /*下面是得到的鍵盤(pán)碼*/ 00 00 1e 00 00 00 00 00 //'1' 00 00 00 00 00 00 00 00 00 00 1f 00 00 00 00 00 //'2' 00 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 //'3' 00 00 00 00 00 00 00 00 00 00 21 00 00 00 00 00 //'4' 00 00 00 00 00 00 00 00 //順便問(wèn)一下,這是什么編碼形式?為何和ASC碼、Unicode碼都對(duì)不上?
我的USB設(shè)備配置如下: 12 01 00 01 00 00 00 08 b4 04 00 01 01 00 01 02 00 01 config 09 02 22 00 01 01 04 a0 32 config 2 09 02 22 00 01 01 04 a0 32 09 04 00 00 01 03 01 01 05 09 21 00 01 00 01 22 3f 00 07 05 81 03 08 00 0a set idle report 05 01 09 06 a1 01 05 07 19 e0 29 e7 15 00 25 01 75 01 95 08 81 02 95 01 75 08 81 01 95 05 75 01 05 08 19 01 29 05 91 02 95 01 75 03 91 01 95 06 75 08 15 00 25 ff 05 07 19 00 29 ff 81 00 c0 set report /*下面是發(fā)來(lái)的數(shù)據(jù),本應(yīng)該是一個(gè)14字節(jié)長(zhǎng)度的數(shù)據(jù),但是卻只收到了8個(gè)0*/ 00 00 00 00 00 00 00 00
之后我又用bushound抓取了與PC連接時(shí)的數(shù)據(jù):
USB鍵盤(pán)的如下(字符“1”的數(shù)據(jù)流): Device Phase Data Description Cmd.Phase.Ofs(rep) ------ ----- ------------------------------------------------------------------------------------------------------ ---------------- ------------------ 25 LEN 09 00 00 00 9 1.1.0 25 DI 00 00 00 1e 00 00 00 00 00 ......... 1.2.0 25 IRP 06 00 48 01 f8 59 47 87 00 00 00 00 00 00 00 00 08 3b 4f 87 08 3b 4f 87 00 00 00 00 09 00 00 00 1.3.0 25 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 bd aa 88 18 b7 bf 88 9a ad 79 a9 READ 1.4.0 25 LEN 09 00 00 00 9 2.1.0 25 DI 00 00 00 00 00 00 00 00 00 ......... 2.2.0 25 IRP 06 00 48 01 f8 59 47 87 00 00 00 00 00 00 00 00 08 3b 4f 87 08 3b 4f 87 00 00 00 00 09 00 00 00 2.3.0 25 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 28 bd aa 88 18 b7 bf 88 9a ad 79 a9 READ 2.4.0
下面是USB設(shè)備一次發(fā)來(lái)的數(shù)據(jù)流(每次都發(fā)送14字節(jié)有效數(shù)據(jù),如下例中的‘23 26 1f 21 26 22 21 1e 20 27 24 1f 23 28’): Device Phase Data Description Cmd.Phase.Ofs(rep) ------ ----- ------------------------------------------------------------------------------------------------------ ---------------- ------------------ 27 LEN 09 00 00 00 9 1.1.0 27 DI 00 00 00 23 26 1f 21 26 22 ...#&.!&" 1.2.0 27 IRP 06 00 48 01 48 dc b1 88 00 00 00 00 00 00 00 00 48 22 50 87 48 22 50 87 00 00 00 00 09 00 00 00 1.3.0 27 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 d4 61 89 48 c9 c7 88 9a ad 79 a9 READ 1.4.0 27 LEN 09 00 00 00 9 2.1.0 27 DI 00 00 00 00 00 00 00 00 00 ......... 2.2.0 27 IRP 06 00 48 01 48 dc b1 88 00 00 00 00 00 00 00 00 48 22 50 87 48 22 50 87 00 00 00 00 09 00 00 00 2.3.0 27 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 d4 61 89 48 c9 c7 88 9a ad 79 a9 READ 2.4.0 27 LEN 09 00 00 00 9 3.1.0 27 DI 00 00 00 21 1e 20 27 24 1f ...!. '$. 3.2.0 27 IRP 06 00 48 01 48 dc b1 88 00 00 00 00 00 00 00 00 48 22 50 87 48 22 50 87 00 00 00 00 09 00 00 00 3.3.0 27 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 d4 61 89 48 c9 c7 88 9a ad 79 a9 READ 3.4.0 27 LEN 09 00 00 00 9 4.1.0 27 DI 00 00 00 00 00 00 00 00 00 ......... 4.2.0 27 IRP 06 00 48 01 48 dc b1 88 00 00 00 00 00 00 00 00 48 22 50 87 48 22 50 87 00 00 00 00 09 00 00 00 4.3.0 27 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 d4 61 89 48 c9 c7 88 9a ad 79 a9 READ 4.4.0 27 LEN 09 00 00 00 9 5.1.0 27 DI 00 00 00 23 28 00 00 00 00 ...#(.... 5.2.0 27 IRP 06 00 48 01 48 dc b1 88 00 00 00 00 00 00 00 00 48 22 50 87 48 22 50 87 00 00 00 00 09 00 00 00 5.3.0 27 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 d4 61 89 48 c9 c7 88 9a ad 79 a9 READ 5.4.0 27 LEN 09 00 00 00 9 6.1.0 27 DI 00 00 00 00 00 00 00 00 00 ......... 6.2.0 27 IRP 06 00 48 01 48 dc b1 88 00 00 00 00 00 00 00 00 48 22 50 87 48 22 50 87 00 00 00 00 09 00 00 00 6.3.0 27 STAK 03 00 00 e0 09 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 d8 d4 61 89 48 c9 c7 88 9a ad 79 a9 READ 6.4.0
本人剛開(kāi)始讀USB協(xié)議,只是略懂點(diǎn)皮毛,分析配置描述符還是很困難的,所以還請(qǐng)有經(jīng)驗(yàn)的前輩給我指一條路,我該如何配置我的這個(gè)設(shè)備? 實(shí)驗(yàn)做下來(lái),我知道完全按照USB鍵盤(pán)的配置是行不通的,但就是找不到關(guān)鍵的配置點(diǎn)。 希望版主能指點(diǎn)一下此USB設(shè)備該如何配置!多謝了! 期待前輩指點(diǎn)中。。。[Emot]19[/Emot]