2014-05-03 65 views
0

我试图实现USB设备。有一个实现HID的示例代码。我更改了配置描述符,并且设备从设备中消失(lsusb)我不知道哪里出了问题,因为我根据CDC文档进行了说明。这里是他的配置描述符:配置描述符更改后无法识别USB设备

static unsigned char ConfigDescr[]= // CONFIGURATION Descriptor 
{ 
    0x09,  // bLength 
    0x02,  // bDescriptorType = Config 
    0x43,0x00, // wTotalLength(L/H) = 67 bytes 
    0x02,  // bNumInterfaces 
    0x01,  // bConfigValue 
    0x00,  // iConfiguration 
    0xE0,  // bmAttributes. b7=1 b6=self-powered b5=RWU supported 
    0x01,  // MaxPower is 2 ma 
// INTERFACE Descriptor 
    0x09,  // length = 9 
    0x04,  // type = IF 
    0x00,  // IF #0 
    0x00,  // bAlternate Setting 
    0x01,  // bNum Endpoints 
    0x02,  // bInterfaceClass = Communucations 
    0x02,0x01, // bInterfaceSubClass=Abstract (modem), bInterfaceProtocol=AT-commands (v.25ter) 
    0x00,  // iInterface 
// CDC header 
    0x05,   // bFunctionLength = 5 
    0x24,   // bDescriptorType = CS_INTERFACE 24h 
    0x00,   // bDescriptorSubtype = Header Functional Descriptor 
    0x10, 0x01,  // bcdCDC 
// CDC Call Management 
    0x05,   // bFunctionLength = 5 
    0x24,   // bDescriptorType = CS_INTERFACE 24h 
    0x01,   // bDescriptorSubtype = Call Management 
    0x00,   // bmCapabilities = 0x00 
    0x01,   // bDataInterface 
// CDC Abstract Control Model 
    0x04,   // bFunctionLength = 4 
    0x24,   // bDescriptorType = CS_INTERFACE 24h 
    0x02,   // bDescriptorSubtype = ACM 
    0x02,   // bmCapabilities = 0x02 
// CDC Union 
    0x05,   // bFunctionLength = 5 
    0x24,   // bDescriptorType = CS_INTERFACE 24h 
    0x06,   // bDescriptorSubtype = Union Functional Descriptor 
    0x00,   // bMasterInterface 
    0x01,   // bSlaveInterface 
//Endpoint Descriptor 
    0x07,  // bLength = 7 
    0x05,  // bDescriptorType (Endpoint) 
    0x83,  // bEndpointAddress (EP3-IN) 
    0x03,  // bmAttributes (interrupt) 
    8,0,   // wMaxPacketSize (8) // 8 
    255,  // bInterval (poll every 10 msec) 
// Interface Descriptor 
    0x09,  // length = 9 
    0x04,  // type = IF 
    0x01,  // IF #1 
    0x00,  // bAlternate Setting 
    0x02,  // bNum Endpoints 
    0x0a,  // bInterfaceClass = CDC Data interface 
    0x00,0x00, // bInterfaceSubClass=unused, bInterfaceProtocol=no protocol needed 
    0x00,  // iInterface 
// Endpoint Descriptor 
    0x07,  // bLength 
    0x05,  // bDescriptorType (Endpoint) 
    0x01,  // bEndpointAddress (EP1-OUT) 
    0x02,  // bmAttributes (bulk) 
    64,0,   // wMaxPacketSize (64) 
    0,  // bInterval 
// Endpoint Descriptor 
    0x07,  // bLength 
    0x05,  // bDescriptorType (Endpoint) 
    0x81,  // bEndpointAddress (EP1-IN) 
    0x02,  // bmAttributes (bulk) 
    64,0,   // wMaxPacketSize (64) 
    0};  // bInterval 
+1

连接设备时请检查dmesg输出。此外,还有相对便宜的在线USB协议分析仪,在进行低级USB工作时非常有用。 –

+0

如果它完全消失,你可能会破坏你的固件。但是你仍然应该在dmesg中看到一个未知的器件 - 只需要上拉电阻。我想如果你严重破坏你的固件并且电阻处于软件控制之下,它可能永远不会被激活。 –

+1

Jonathon提到的USB分析仪是一个不错的选择,但在投资硬件之前,先试一个软件(iirc wireshark将在linux上工作)。 –

回答

0

最后,我从制造商那里得到了新的USB库,因为有一个旧的代码。这解决了我的问题,所以我关闭了这个问题。感谢您的帮助!