在描述符中的GET_DEVICE_ID请求返回的信息是怎样的格式呢,可否把usb打印机的整个描述符贴出来呢,小弟感激不尽啊!!!!!!!!!!
你可以自己去抓下描述符不就可以了,并且每个打印机的描述符以及厂商ID都有点不一样的
ID格式的话,大体是前两个字节是ID的长度,后面是MANUFACTURER、COMMAND SET、MODEL、COMMENT等信息,具体的话,以及整个完整的描述符,你得看相应的打印机协议说明文档了。
哦,我想做的是个usb的转接口,我不用理那打印机的具体语言。说到低就是要做作用个模拟打印机的东西就是,只要能实现打印机状态的测试就行。因为这个东西就是要来测试那些有usb口打印的设备是否能正常工作。我给你们看看我的描述,到底是有什么问题。谢谢 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
那是你软件的缓冲区开的不够大
那我这个描述符定义是否正确呢?
如果我想模拟那hp的任一款usb打印机都行,改如果修改,惠普的vid和pid又是什么呢
给我老大,可否给我讲解一下get_device_id,的具体作用呢,还有对返回的数据是做如何处理。给我帮帮忙啊!!!这个问题已经困扰我好几天了
你可以将hp打印机接在电脑上,给它的描述符,vid,Pid抓下不就知道了. get_device_id的作用是用来找驱动的.只有获得了厂商ID,才好装驱动.
哦,这样啊,我已经抓到了,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,这条请求改以什么格式去回复呢?可否帮我写个例子看看呢?这个问题困扰了太久了,一直都没进展啊~多谢你拉,loveapple兄
你是不是模拟出一个HP的USB打印机还是操作一款USB打印机??如果是模拟的话,那么,发个邮件到我们技术信箱,给你一个51的模拟HP打印机的例子程序
十分感谢hcn兄,我已经发邮件了,不知道你们有没有收到。我的邮箱是个人信息保护,已隐藏 再次谢谢你~~