[USB编程]

主机为什么不给我发set configuration

[复制链接]
1906|7
手机看帖
扫描二维码
随时随地手机跟帖
hevry| | 2015-8-27 16:03 | 显示全部楼层
安装驱动了吗?大部分情况还是因为描述符不正确,这样太难看了,是否可以把Source Code贴出来

使用特权

评论回复
xiuwen89| | 2015-8-27 16:11 | 显示全部楼层
可能是没装驱动,也有可能是描述符里面有错误

使用特权

评论回复
恋子炎|  楼主 | 2015-8-27 16:35 | 显示全部楼层
       
//device descriptor
        0x12,        /*bLength*/
        0x01,        /*bDescriptorType*/
        0x00,        /*bcdUSB*/
        0x02,
        0xEF,        /*bDeviceClass   (Miscellaneous device)*/
        0x02,        /*bDeviceSubClass*/   
        0x01,        /*bDeviceProtocol*/   
        0x40,        /*bMaxPacketSize0   (64 Bytes)*/
        0x53,        /*idVendor*/
        0x2B,
        0x53,        /*idProduct*/
        0x17,
        0x00,        /*bcdDevice*/
        0x01,
        0x01,        /*iManufacturer   "SHENZHEN SUPERNATURE MULTIMEDIA CO,.LTD"*/
        /*0x03,        / *iProduct   "Chariot Pro"* /*/
        0x02,        /*iProduct   "Chariot Pro"*/
        0x00,        /*iSerialNumber*/
        0x01        /*bNumConfigurations*/

//config descriptor config 2
        0x09,        bLength
        0x02,        bDescriptorType
        0x69,        wTotalLength
        0x01,
        0x03,        bNumInterfaces
        0x01,        bConfigurationValue
        0x00,        iConfiguration
        0x80,        bmAttributes   (Bus-powered Device)
        0xFA,        bMaxPower   (500 mA)

        Interface Association Descriptor
        0x08,        bLength
        0x0B,        bDescriptorType
        0x00,        bFirstInterface
        0x03,        bInterfaceCount
        0x01,        bFunctionClass   (Audio Device Class)
        0x00,        bFunctionSubClass   
        0x20,        bFunctionProtocol   
        0x00,        iFunction

        Interface Descriptor
        0x09,        bLength
        0x04,        bDescriptorType
        0x00,        bInterfaceNumber
        0x00,        bAlternateSetting
        0x00,        bNumEndPoints
        0x01,        bInterfaceClass   (Audio Device Class)
        0x01,        bInterfaceSubClass   (Audio Control Interface)
        0x20,        bInterfaceProtocol   
        0x03,         iInterface   Chariot Pro
        0x02,        iInterface   Chariot Pro

        AC Interface Header Descriptor
        0x09,        bLength
        0x24,        bDescriptorType
        0x01,        bDescriptorSubtype
        0x00,        bcdADC
        0x02,
        0x08,        bCategory
        0xA7,        wTotalLength
        0x00,
        0x00,        bmControls

        AC Clock Source Descriptor
        0x08,        bLength
        0x24,        bDescriptorType
        0x0A,        bDescriptorSubtype
        0x29,        bClockID
        0x03,        bmAttributes
        0x07,        bmControls
        0x00,        bAssocTerminal
        0x0E,         iClockSource   SHENZHEN SUPERNATURE MULTIMEDIA CO,.LTD Internal Clock
        0x02,        iClockSource   SHENZHEN SUPERNATURE MULTIMEDIA CO,.LTD Internal Clock

        AC Clock Selector Descriptor
        0x08,        bLength
        0x24,        bDescriptorType
        0x0B,        bDescriptorSubtype
        0x28,        bClockID
        0x01,        bNrInPins
        0x29,        baCSourceID(1)
        0x03,        bmControls
        0x0D,         iClockSelector   SHENZHEN SUPERNATURE MULTIMEDIA CO,.LTD Clock Selector
        0x02,        iClockSelector   SHENZHEN SUPERNATURE MULTIMEDIA CO,.LTD Clock Selector

        AC Input Terminal Descriptor
        0x11,        bLength
        0x24,        bDescriptorType
        0x02,        bDescriptorSubtype
        0x02,        bTerminalID
        0x01,        wTerminalType   (USB Streaming)
        0x01,
        0x00,        bAssocTerminal
        0x28,        bCSourceID
        0x08,        bNrChannels
        0x00,0x00,0x00,0x00,bmChannelConfig
        0x10,        iChannelNames
        0x00,        iChannelNames
        0x00,        bmControls
        0x06,         iTerminal   Chariot Pro Output
        0x02,        iTerminal   Chariot Pro Output

        AC Feature Unit Descriptor
        0x2A,        bLength
        0x24,        bDescriptorType
        0x06,        bDescriptorSubtype
        0x0A,        bUnitID
        0x02,        bSourceID
        0x0F,0x00,0x00,0x00,bmaControls(0)
        0x0F,0x00,0x00,0x00,bmaControls(1)
        0x0F,0x00,0x00,0x00,bmaControls(2)
        0x0F,0x00,0x00,0x00,bmaControls(3)
        0x0F,0x00,0x00,0x00,bmaControls(4)
        0x0F,0x00,0x00,0x00,bmaControls(5)
        0x0F,0x00,0x00,0x00,bmaControls(6)
        0x0F,0x00,0x00,0x00,bmaControls(7)
        0x0F,0x00,0x00,0x00,bmaControls(8)
        0x00,        iFeature

        AC Output Terminal Descriptor
        0x0C,        bLength
        0x24,        bDescriptorType
        0x03,        bDescriptorSubtype
        0x14,        bTerminalID
        0x01,        wTerminalType   (Speaker)
        0x03,
        0x00,        bAssocTerminal
        0x0A,        bSourceID
        0x28,        bCSourceID
        0x00,        bmControls
        0x00,
        0x00,        iTerminal

        AC Input Terminal Descriptor
        0x11,        bLength
        0x24,        bDescriptorType
        0x02,        bDescriptorSubtype
        0x01,        bTerminalID
        0x01,        wTerminalType   (Microphone)
        0x02,
        0x00,        bAssocTerminal
        0x28,        bCSourceID
        0x08,        bNrChannels       
        0x00,0x00,0x00,0x00,bmChannelConfig
        0x18,        iChannelNames
        0x00,
        0x00,        bmControls
        0x00,        iTerminal

        AC Feature Unit Descriptor
        0x2A,        bLength
        0x24,        bDescriptorType
        0x06,        bDescriptorSubtype
        0x0B,        bUnitID
        0x01,        bSourceID
        0x0F,0x00,0x00,0x00,bmaControls(0)
        0x0F,0x00,0x00,0x00,bmaControls(1)
        0x0F,0x00,0x00,0x00,bmaControls(2)
        0x0F,0x00,0x00,0x00,bmaControls(3)
        0x0F,0x00,0x00,0x00,bmaControls(4)
        0x0F,0x00,0x00,0x00,bmaControls(5)
        0x0F,0x00,0x00,0x00,bmaControls(6)
        0x0F,0x00,0x00,0x00,bmaControls(7)
        0x0F,0x00,0x00,0x00,bmaControls(8)
        0x00,        iFeature

        AC Output Terminal Descriptor
        0x0C,        bLength
        0x24,        bDescriptorType
        0x03,        bDescriptorSubtype
        0x16,        bTerminalID
        0x01,        wTerminalType   (USB Streaming)
        0x01,
        0x00,        bAssocTerminal
        0x0B,        bSourceID
        0x28,        bCSourceID
        0x00,        bmControls
        0x00,
        0x07,         iTerminal   Chariot Pro Input
        0x02,        iTerminal   Chariot Pro Input

        Interface Descriptor
        0x09,        bLength
        0x04,        bDescriptorType
        0x01,        bInterfaceNumber
        0x00,        bAlternateSetting
        0x00,        bNumEndPoints
        0x01,        bInterfaceClass   (Audio Device Class)
        0x02,        bInterfaceSubClass   (Audio Streaming Interface)
        0x20,        bInterfaceProtocol   
        0x04,         iInterface   Chariot Pro Output
        0x02,        iInterface   Chariot Pro Output

        Interface Descriptor
        0x09,        bLength
        0x04,        bDescriptorType
        0x01,        bInterfaceNumber
        0x01,        bAlternateSetting
        0x02,        bNumEndPoints
        0x01,        bInterfaceClass   (Audio Device Class)
        0x02,        bInterfaceSubClass   (Audio Streaming Interface)
        0x20,        bInterfaceProtocol   
        0x04,         iInterface   Chariot Pro Output
        0x02,        iInterface   Chariot Pro Output

        AS Interface Descriptor
        0x10,        bLength
        0x24,        bDescriptorType
        0x01,        bDescriptorSubtype
        0x02,        bTerminalLink
        0x00,        bmControls
        0x01,        bFormatType
        0x01,0x00,0x00,0x00,
        0x08,        bNrChannels
        0x00,0x00,0x00,0x00,
        0x10,         iChannelNames
        0x02,        iChannelNames

        AS Format Type 1 Descriptor
        0x06,        bLength
        0x24,        bDescriptorType
        0x02,        bDescriptorSubtype
        0x01,        bFormatType
        0x04,        bSubslotSize
        0x18,        bBitResolution   (24 Bitssample)
       
        Endpoint Descriptor
        0x07,        bLength
        0x05,        bDescriptorType
        0x01,        bEndpointAddress   (OUT Endpoint)
        0x05,        bmAttributes        (Transfer Isochronous  Synch Asynchronous  Usage Data)
        0x20,        wMaxPacketSize   (800 Bytes)
        0x03,
        0x01,        bInterval
       
        AS Isochronous Data Endpoint Descriptor
        0x08,        bLength
        0x25,        bDescriptorType
        0x01,        bDescriptorSubtype
        0x00,        bmAttributes
        0x00,        bmControls
        0x02,        bLockDelayUnits   (Decoded PCM samples)
        0x08,        wLockDelay
        0x00,

        Endpoint Descriptor
        0x07,        bLength
        0x05,        bDescriptorType
        0x81,        bEndpointAddress   (IN Endpoint)
        0x11,        bmAttributes        (Transfer Isochronous  Synch None  Usage Feedback)
        0x04,        wMaxPacketSize   (4 Bytes)
        0x00,
        0x04,        bInterval

        Interface Descriptor
        0x09,        bLength
        0x04,        bDescriptorType
        0x01,        bInterfaceNumber
        0x02,        bAlternateSetting
        0x02,        bNumEndPoints
        0x01,        bInterfaceClass   (Audio Device Class)
        0x02,        bInterfaceSubClass   (Audio Streaming Interface)
        0x20,        bInterfaceProtocol   
        0x04,         iInterface   Chariot Pro Output
        0x02,        iInterface   Chariot Pro Output

        AS Interface Descriptor
        0x10,        bLength
        0x24,        bDescriptorType
        0x01,        bDescriptorSubtype
        0x02,        bTerminalLink
        0x00,        bmControls
        0x01,        bFormatType
        0x01,0x00,0x00,0x00,
        0x08,        bNrChannels
        0x00,0x00,0x00,0x00,
        0x10,         iChannelNames
        0x02,        iChannelNames

        AS Format Type 1 Descriptor
        0x06,        bLength
        0x24,        bDescriptorType
        0x02,        bDescriptorSubtype
        0x01,        bFormatType
        0x02,        bSubslotSize
        0x10,        bBitResolution   (16 Bitssample)

        Endpoint Descriptor
        0x07,        bLength
        0x05,        bDescriptorType
        0x01,        bEndpointAddress   (OUT Endpoint)
        0x05,        bmAttributes        (Transfer Isochronous  Synch Asynchronous  Usage Data)
        0x90,        wMaxPacketSize   (400 Bytes)
        0x01,
        0x01,        bInterval

        AS Isochronous Data Endpoint Descriptor
        0x08,        bLength
        0x25,        bDescriptorType
        0x01,        bDescriptorSubtype
        0x00,        bmAttributes
        0x00,        bmControls
        0x02,        bLockDelayUnits   (Decoded PCM samples)
        0x08,        wLockDelay
        0x00,

        Endpoint Descriptor
        0x07,        bLength
        0x05,        bDescriptorType
        0x81,        bEndpointAddress   (IN Endpoint)
        0x11,        bmAttributes        (Transfer Isochronous  Synch None  Usage Feedback)
        0x04,        wMaxPacketSize   (4 Bytes)
        0x00,
        0x04,        bInterval

        Interface Descriptor
        0x09,        bLength
        0x04,        bDescriptorType
        0x02,        bInterfaceNumber
        0x00,        bAlternateSetting
        0x00,        bNumEndPoints
        0x01,        bInterfaceClass   (Audio Device Class)
        0x02,        bInterfaceSubClass   (Audio Streaming Interface)
        0x20,        bInterfaceProtocol   
        0x05,         iInterface   Chariot Pro Input
        0x02,        iInterface   Chariot Pro Input

        Interface Descriptor
        0x09,        bLength
        0x04,        bDescriptorType
        0x02,        bInterfaceNumber
        0x01,        bAlternateSetting
        0x01,        bNumEndPoints
        0x01,        bInterfaceClass   (Audio Device Class)
        0x02,        bInterfaceSubClass   (Audio Streaming Interface)
        0x20,        bInterfaceProtocol   
        0x05,         iInterface   Chariot Pro Input
        0x02,        iInterface   Chariot Pro Input
       
        AS Interface Descriptor
        0x10,        bLength
        0x24,        bDescriptorType
        0x01,        bDescriptorSubtype
        0x16,        bTerminalLink
        0x00,        bmControls
        0x01,        bFormatType
        0x01,0x00,0x00,0x00,
        0x08,        bNrChannels
        0x00,0x00,0x00,0x00,
        0x18,         iChannelNames
        0x02,        iChannelNames

        AS Format Type 1 Descriptor
        0x06,        bLength
        0x24,        bDescriptorType
        0x02,        bDescriptorSubtype
        0x01,        bFormatType
        0x04,        bSubslotSize
        0x18,        bBitResolution   (24 Bitssample)

        Endpoint Descriptor
        0x07,        bLength
        0x05,        bDescriptorType
        0x82,        bEndpointAddress   (IN Endpoint)
        0x05,        bmAttributes        (Transfer Isochronous  Synch Asynchronous  Usage Data)
        0x20,        wMaxPacketSize   (800 Bytes)
        0x03,
        0x01,        bInterval

        AS Isochronous Data Endpoint Descriptor
        0x08,        bLength
        0x25,        bDescriptorType
        0x01,        bDescriptorSubtype
        0x00,        bmAttributes
        0x00,        bmControls
        0x02,        bLockDelayUnits   (Decoded PCM samples)
        0x08,        wLockDelay
        0x00

以上是描述符,大家辛苦了

使用特权

评论回复
hevry| | 2015-8-27 19:50 | 显示全部楼层
给楼主介绍一个工具
usblyzer可能可以帮到你解析主机读到的描述符信息

使用特权

评论回复
jinxuan97| | 2017-11-15 10:11 | 显示全部楼层
楼主问题怎么解决的? 我有另一个问题: Audio Input 有严重噪声. 希望请教!

使用特权

评论回复
jinxuan97| | 2017-11-16 15:44 | 显示全部楼层
Audio Input 的噪声解决了,是因为Android系统的限制.

5.4.1. Raw Audio Capture (android-7.1-cdd.pdf)
Device implementations that declare android.hardware.microphone MUST allow capture of raw audio content with the following characteristics:
- Format : Linear PCM, 16-bit
- Sampling rates : 8000, 11025, 16000, 44100
- Channels : Mono

Device implementations that declare android.hardware.microphone SHOULD allow capture of raw
audio content with the following characteristics:
- Format : Linear PCM, 16-bit
- Sampling rates : 22050, 48000
- Channels : Stereo

使用特权

评论回复
zhs2007| | 2017-11-18 15:31 | 显示全部楼层
楼主的配置描述符中有错误,电脑当然就不识别了
用带协议解析功能的设备抓个包,一眼就能发现问题所在了

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

15

主题

78

帖子

1

粉丝