在描述符中的GET_DEVICE_ID請求返回的信息是怎樣的格式呢,可否把usb打印機的整個描述符貼出來呢,小弟感激不盡?。。。。。。。。。?!
你可以自己去抓下描述符不就可以了,并且每個打印機的描述符以及廠商ID都有點不一樣的
ID格式的話,大體是前兩個字節(jié)是ID的長度,后面是MANUFACTURER、COMMAND SET、MODEL、COMMENT等信息,具體的話,以及整個完整的描述符,你得看相應(yīng)的打印機協(xié)議說明文檔了。
哦,我想做的是個usb的轉(zhuǎn)接口,我不用理那打印機的具體語言。說到低就是要做作用個模擬打印機的東西就是,只要能實現(xiàn)打印機狀態(tài)的測試就行。因為這個東西就是要來測試那些有usb口打印的設(shè)備是否能正常工作。我給你們看看我的描述,到底是有什么問題。謝謝 DeviceDscr: db DSCR_DEVICE_LEN ;; Descriptor length db DSCR_DEVICE ;; Decriptor type dw 0002H ;; Specification Version (BCD) db 00H ;; Device class db 00H ;; Device sub-class db 00H ;; Device sub-sub-class db 64 ;; Maximum packet size /* dw 4705H ;; Vendor ID dw 0210H ;; Product ID (Sample Device) dw 0000H ;; Product version ID */ dw 03F0H ;; Vendor ID dw 2C17H ;; Product ID (Sample Device) dw 0100H ;; Product version ID db 1 ;; Manufacturer string index db 2 ;; Product string index db 0 ;; Serial number string index db 1 ;; Number of configurations
DeviceQualDscr: db DSCR_DEVQUAL_LEN ;; Descriptor length db DSCR_DEVQUAL ;; Decriptor type dw 0002H ;; Specification Version (BCD) db 00H ;; Device class db 00H ;; Device sub-class db 00H ;; Device sub-sub-class db 64 ;; Maximum packet size db 1 ;; Number of configurations db 0 ;; Reserved
FullSpeedConfigDscr: db DSCR_CONFIG_LEN ;; Descriptor length db DSCR_CONFIG ;; Descriptor type db (FullSpeedConfigDscrEnd-FullSpeedConfigDscr) mod 256 ;; Total Length (LSB) db (FullSpeedConfigDscrEnd-FullSpeedConfigDscr) / 256 ;; Total Length (MSB) db 1 ;; Number of interfaces db 1 ;; Configuration number db 0 ;; Configuration string db 10000000b ;; Attributes (b7 - buspwr, b6 - selfpwr, b5 - rwu) db 50 ;; Power requirement (div 2 ma)
;; Interface Descriptor db DSCR_INTRFC_LEN ;; Descriptor length db DSCR_INTRFC ;; Descriptor type db 0 ;; Zero-based index of this interface db 0 ;; Alternate setting db 2 ;; Number of end points ; ; db 0ffH ;; Interface class ;; db 00H ;; Interface sub class ;; db 00H ;; Interface sub sub class ;; db 0 ;; Interface descriptor string index
db 07H ;; Interface class db 01H ;; Interface sub class db 02H ;; Interface sub sub class db 0 ;; Interface descriptor string index
;; Endpoint Descriptor db DSCR_ENDPNT_LEN ;; Descriptor length db DSCR_ENDPNT ;; Descriptor type db 02H ;; Endpoint number, and direction db ET_BULK ;; Endpoint type db 40H ;; Maximun packet size (LSB) db 00H ;; Max packect size (MSB) db 00H ;; Polling interval
;; Endpoint Descriptor db DSCR_ENDPNT_LEN ;; Descriptor length db DSCR_ENDPNT ;; Descriptor type db 04H ;; Endpoint number, and direction db ET_BULK ;; Endpoint type db 40H ;; Maximun packet size (LSB) db 00H ;; Max packect size (MSB) db 00H ;; Polling interval
;; Endpoint Descriptor db DSCR_ENDPNT_LEN ;; Descriptor length db DSCR_ENDPNT ;; Descriptor type db 86H ;; Endpoint number, and direction db ET_BULK ;; Endpoint type db 40H ;; Maximun packet size (LSB) db 00H ;; Max packect size (MSB) db 00H ;; Polling interval
;; Endpoint Descriptor db DSCR_ENDPNT_LEN ;; Descriptor length db DSCR_ENDPNT ;; Descriptor type db 88H ;; Endpoint number, and direction db ET_BULK ;; Endpoint type db 40H ;; Maximun packet size (LSB) db 00H ;; Max packect size (MSB) db 00H ;; Polling interval
FullSpeedConfigDscrEnd:
StringDscr:
StringDscr0: db StringDscr0End-StringDscr0 ;; String descriptor length db DSCR_STRING db 09H,04H StringDscr0End:
StringDscr1: db StringDscr1End-StringDscr1 ;; String descriptor length db DSCR_STRING db 'C',00 db 'y',00 db 'p',00 db 'r',00 db 'e',00 db 's',00 db 's',00 StringDscr1End:
StringDscr2: db StringDscr2End-StringDscr2 ;; Descriptor length db DSCR_STRING db 'E',00 db 'Z',00 db '-',00 db 'U',00 db 'S',00 db 'B',00 db ' ',00 db 'F',00 db 'X',00 db '2',00 StringDscr2End:
DeviceIdDscr: db (DeviceIdDscrEnd-DeviceIdDscr)mod 256 db (DeviceIdDscrEnd-DeviceIdDscr)/ 256 db 'M',00,'F',00,'G',00,':',00,'H',00,'e',00,'w',00,'l',00,'e',00,'t',00,'t',00,'-',00,'P',00,'a',00,'c',00,'k',00,'a',00,'r',00,'d',00,';',00 db 'M',00,'D',00,'L',00,':',00,'H',00,'P',00,' ',00,'L',00,'a',00,'s',00,'e',00,'r',00,'J',00,'e',00,'t',00,'1',00,'0',00,'2',00,'2',00,';',00 db 'C',00,'M',00,'D',00,':',00,'A',00,'C',00,'L',00,';',00 db 'C',00,'L',00,'S',00,':',00,'P',00,'R',00,'I',00,'N',00,'T',00,'E',00,'R',00,';',00 db 'D',00,'E',00,'S',00,':',00,'H',00,'P',00,' ',00,'L',00,'a',00,'s',00,'e',00,'r',00,'J',00,'e',00,'t',00,'1',00,'0',00,'2',00,'2',00,';',00 db 'F',00,'W',00,'V',00,'E',00,'R',00,':',00,'2',00,'0',00,'0',00,'7',00,'0',00,'4',00,'1',00,'7',00,';',00 DeviceIdDscrEnd:
UserDscr: dw 0000H end
抓取的描述符,那個get device id 怎么一半可就沒了呢? Bus Hound 5.00 capture. Complements of www.perisoft.net
dd
Device - Device ID (followed by the endpoint for USB devices) (17) USB 列印支援 (18) Cypress EZ-USB FX2 Development Board Phase - Phase Type CTL USB control transfer DI Data in DO Data out USTS USB status 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) ------ ----- -------------------------------------------------- ---------------- ------------------ 17.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 99.1.0 17.0 DI 12 01 00 02 00 00 00 40 03 f0 2c 17 01 00 01 02 .......@..,..... 99.2.0 00 01 .. 99.2.16 17.0 CTL 80 06 00 02 00 00 09 01 GET DESCRIPTOR 100.1.0 17.0 DI 09 02 2e 00 01 01 00 80 32 09 04 00 00 02 07 01 ........2....... 100.2.0 02 00 07 05 02 02 40 00 00 07 05 04 02 40 00 00 ......@......@.. 100.2.16 17.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 101.1.0 17.0 CTL a1 00 00 00 00 00 f1 03 GET DEVICE ID 102.1.0 17.0 DI c1 00 4d 00 46 00 47 00 3a 00 48 00 65 00 77 00 ..M.F.G.:.H.e.w. 102.2.0 6c 00 65 00 74 00 74 00 2d 00 50 00 61 00 63 00 l.e.t.t.-.P.a.c. 102.2.16 17.0 USTS 04 00 00 c0 stall pid 102.3.0
那是你軟件的緩沖區(qū)開的不夠大
那我這個描述符定義是否正確呢?
如果我想模擬那hp的任一款usb打印機都行,改如果修改,惠普的vid和pid又是什么呢
給我老大,可否給我講解一下get_device_id,的具體作用呢,還有對返回的數(shù)據(jù)是做如何處理。給我?guī)蛶兔Π。。?!這個問題已經(jīng)困擾我好幾天了
你可以將hp打印機接在電腦上,給它的描述符,vid,Pid抓下不就知道了. get_device_id的作用是用來找驅(qū)動的.只有獲得了廠商ID,才好裝驅(qū)動.
哦,這樣啊,我已經(jīng)抓到了,hp deskjet 3848 的描述符了:如下 us Hound 5.00 capture. Complements of www.perisoft.net
Device - Device ID (followed by the endpoint for USB devices) (18) USB 列印支援 (19) (20) USB 列印支援 (21) HP Deskjet 3840 Series Phase - Phase Type CTL USB control transfer DI Data in LEN Data length URB USB request block 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) ------ ----- -------------------------------------------------- ---------------- ------------------
20.0 CTL 80 06 00 02 00 00 09 01 GET DESCRIPTOR 6.1.0 20.0 LEN 20 00 00 00 32 6.2.0
20.0 DI 09 02 20 00 01 01 00 c0 01 09 04 00 00 02 07 01 .. ............. 6.3.0 02 00 07 05 01 02 40 00 00 07 05 82 02 40 00 00 ......@......@.. 6.3.16 20.0 URB 50 00 08 00 00 00 00 00 48 4c 20 81 03 00 00 00 CONTROL TRANSFER 6.4.0 54 4c 20 81 47 00 65 00 20 00 00 00 48 04 a3 ff 6.4.16 88 9f a4 ff 00 00 00 00 88 49 14 81 e8 d1 1c 81 6.4.32 cc 49 14 81 cc 49 14 81 00 00 75 00 73 00 62 00 6.4.48 70 00 72 00 00 00 00 00 80 06 00 02 00 00 09 01 6.4.64 20.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 7.1.0 20.0 URB 50 00 00 00 00 00 00 00 48 4c 20 81 00 00 00 00 SELECT CONFIG 7.2.0 48 04 a3 ff a8 fe 99 e7 38 00 00 00 07 01 02 00 7.2.16 08 f8 b0 ff 02 00 00 00 40 00 01 00 02 00 00 00 7.2.32 20 f8 b0 ff 00 10 00 00 00 00 00 00 40 00 82 00 7.2.48 02 00 00 00 3c f8 b0 ff 00 10 00 00 00 00 00 00 7.2.64 20.0 CTL a1 00 00 00 00 00 f1 03 GET DEVICE ID 8.1.0 20.0 LEN 79 00 00 00 121 8.2.0 20.0 DI 00 79 4d 46 47 3a 48 50 3b 4d 44 4c 3a 44 65 73 .yMFG:HP;MDL:Des 8.3.0 6b 6a 65 74 20 33 38 34 30 3b 43 4d 44 3a 4c 44 kjet 3840;CMD:LD 8.3.16 4c 2c 44 59 4e 3b 43 4c 53 3a 50 52 49 4e 54 45 L,DYN;CLS:PRINTE 8.3.32 52 3b 44 45 53 3a 33 38 34 38 3b 53 4e 3a 54 48 R;DES:3848;SN:TH 8.3.48 35 36 42 31 34 30 38 36 30 34 36 43 3b 53 3a 30 56B14086046C;S:0 8.3.64 33 38 30 30 30 38 30 30 30 30 32 30 30 32 30 32 3800080000200202 8.3.80 33 32 66 66 66 38 31 30 30 30 66 66 66 38 31 30 32fff81000fff810 8.3.96 30 30 3b 5a 3a 30 30 37 3b 00;Z:007; 8.3.112 20.0 URB 50 00 08 00 00 00 00 00 48 4c 20 81 03 00 00 00 CONTROL TRANSFER 8.4.0 54 4c 20 81 03 00 00 00 79 00 00 00 e8 bb a2 ff 8.4.16 88 9f a4 ff 00 00 00 00 88 49 14 81 08 c0 a5 ff 8.4.32 cc 49 14 81 cc 49 14 81 00 00 00 00 00 00 00 00 8.4.48 00 00 00 00 00 00 00 00 a1 00 00 00 00 00 f1 03 8.4.64
請問我對get_device_id,這條請求改以什么格式去回復(fù)呢?可否幫我寫個例子看看呢?這個問題困擾了太久了,一直都沒進展啊~多謝你拉,loveapple兄
你是不是模擬出一個HP的USB打印機還是操作一款USB打印機??如果是模擬的話,那么,發(fā)個郵件到我們技術(shù)信箱,給你一個51的模擬HP打印機的例子程序
十分感謝hcn兄,我已經(jīng)發(fā)郵件了,不知道你們有沒有收到。我的郵箱是個人信息保護,已隱藏 再次謝謝你~~