要实现的是still image capture & PTP
descriptor 如下:
const u8 SIC_DeviceDescriptor[SIC_SIZ_DEVICE_DESC] ={ 0x12, /* bLength */ 0x01, /* bDescriptorType */ 0x00, /* bcdUSB, version 1.00 */ 0x01, 0x00, /* bDeviceClass : See interface */ 0x00, /* bDeviceSubClass : See interface*/ 0x00, /* bDeviceProtocol : See interface */ 0x08, /* bMaxPacketSize0 0x40 = 64 */ 0x83, /* idVendor (0483) */ 0x04, 0xb4, /* idProduct */ 0x14, 0x1A, /* bcdDevice*/ 0x01, 0x01, /* iManufacturer : index of string Manufacturer */ 0x02, /* iProduct : index of string descriptor of product */ 0x03, /* iSerialNumber : index of string serial number */ 0x01 /* bNumConfigurations */ };
const u8 SIC_ConfigDescriptor[SIC_SIZ_CONFIG_DESC] = { 0x09, /* bLength: Configuation Descriptor size */ 0x02, /* bDescriptorType: Configuration */ SIC_SIZ_CONFIG_DESC, /* wTotalLength: Bytes returned */ 0x00, 0x01, /* bNumInterfaces: 1 interface */ 0x01, /* bConfigurationValue: Configuration value */ 0x00, /* iConfiguration: Index of string descriptor describing the configuration */ 0x80, /* bmAttributes: bus powered */ 0x52, /* MaxPower 100 mA: this current is used for detecting Vbus */ /* 09 */
/*** Descriptor of DFU interface 0 Alternate setting 0 ***/ 0x09, /* bLength: Interface Descriptor size */ 0x04, /* bDescriptorType: */ 0x00, /* bInterfaceNumber: Number of Interface */ 0x00, /* bAlternateSetting: Alternate setting */ 0x03, /* bNumEndpoints*/ 0x06, /* bInterfaceClass: SIC */ 0x01, /* bInterfaceSubClass */ 0x01, /* nInterfaceProtocol :PTP*/ 0x04, /* iInterface: */ /* 18 */ 0x07, /* bLength: Endpoint Descriptor size */ 0x05, /* bDescriptorType: */ 0x81, /* bEndpointAddress: */ 0x02, /* bmAttributes: bulk transfers */ 0x40, /* wMaxPacketSize:64 bytes */ 0x00, 0x00, /* bInterval:Ignored */ /* 25 */ 0x07, /* bLength: Endpoint Descriptor size */ 0x05, /* bDescriptorType: */ 0x01, /* bEndpointAddress: */ 0x02, /* bmAttributes: bulk transfers */ 0x40, /* wMaxPacketSize:64 bytes */ 0x00, 0x00, /* bInterval:Ignored */ /* 32 */ 0x07, /* bLength: Endpoint Descriptor size */ 0x05, /* bDescriptorType: */ 0x83, /* bEndpointAddress: */ 0x03, /* bmAttributes: interrupt transfers */ 0x40, /* wMaxPacketSize:64 bytes */ 0x00, 0x00, /* bInterval:Ignored */ /* 39 */ }; /* SIC_ConfigDescriptor */
可以把基本的descriptor给传上去,pc识别为digital still camera。 一下为BUS HOUND的监控结果: **************************************************** *************** monitor start ********************** **************************************************** Bus Hound 5.00 capture. Complements of www.perisoft.net
Device - Device ID (followed by the endpoint for USB devices) (20) Digital Still Camera Phase - Phase Type CTL USB control transfer DI Data in RSET bus reset 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) ------ ----- -------------------------------------------------- ---------------- ------------------ 20.0 CTL 80 06 00 01 00 00 12 00 GET DESCRIPTOR 1.1.0 20.0 DI 12 01 00 01 00 00 00 08 83 04 b4 14 1a 01 01 02 ................ 1.2.0 03 01 .. 1.2.16 20.0 CTL 80 06 00 02 00 00 09 00 GET DESCRIPTOR 2.1.0 20.0 DI 09 02 27 00 01 01 00 80 52 ..'.....R 2.2.0 20.0 CTL 80 06 00 02 00 00 27 00 GET DESCRIPTOR 3.1.0 20.0 DI 09 02 27 00 01 01 00 80 52 09 04 00 00 03 06 01 ..'.....R....... 3.2.0 01 04 07 05 81 02 40 00 00 07 05 03 02 40 00 00 ......@......@.. 3.2.16 07 05 83 03 40 00 00 ....@.. 3.2.32 20.0 CTL 00 09 01 00 00 00 00 00 SET CONFIG 4.1.0 20.0 CTL a1 67 00 00 00 00 24 00 GET DEVICE STS 5.1.0 20.0 DI 18 00 01 20 81 81 81 81 81 81 81 81 81 81 81 81 ... ............ 5.2.0 81 81 81 81 81 81 81 81 ........ 5.2.16 20.1 RSET 6.1.0
**************************************************** *************** monitor end ************************ ****************************************************
最后一步20.1 RSET,但是我监控的实际是clear feature: 02 01 00 81 00 still image capture的spec上指明如果不支持feature则返回stall,我照做了,但没效果,卡在这边了!!! 从上一步讲:20.0 GET DEVICE STS,这个命令到底要回什么呢? 关于这个命令的回复,spec上写得有点难明白,请参照still image capture的spec1.0的11页。
在线等,急!!!
相关链接:https://bbs.21ic.com/upfiles/img/20082/20082482826899.pdf |