2014-05-03 83 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庫,因爲有一箇舊的代碼。這解決了我的問題,所以我關閉了這個問題。感謝您的幫助!