阅读:1948回复:6
HI,大家好,问大家一个关于HID设备report descriptor 的问题
该设备现在处可以打开,但是既不能写,也不能读的状态,应用程序
执行ReadFile后程序就死了,执行WriteFile后报错1784 为什么,盼大家给予指点。 PS:CREATEFILE 正常。偶怀疑是FIRMWARE中report descriptor 的问题,但又不明白哪里除了问题,谁能给偶一些提示。 _rom BYTE Dev_Descp[] = { DEV_LEN, // bLength: Size of descriptor 0x01, // bDescriptorType: Device 0x10,0x01, // bcdUSB: USB 1.1 0x00, // bDeviceClass: none 0x00, // bDeviceSubClass: none 0x00, // bDeviceProtocol: none EP0_LEN, // bMaxPacketSize0: 8/64 bytes 0xB4,0x04, // idVendor: 0x04B4 - Cypress 0x11,0x08, // idProduct: 0x1111 - SL811S 0x00,0x01, // bcdDevice: version 1.0 0x01, // iManufacturer: Cypress 0x02, // iProduct: Cypress SL811S - HID Consumer Control 0x00, // iSerialNumber: none 0x01}; // bNumConfigurations: 1 //--------------------------------------------------------------------------------------------------------------------- // CONFIGURATION DESCRIPTOR //--------------------------------------------------------------------------------------------------------------------- _rom BYTE Cfg_Descp[] = { 0x09, // bLength: Size of descriptor 0x02, // bDescriptorType: Configuration CFG_LEN,0x00, // wTotalLength: Cfg+Ifc+Class+Ep = 34 bytes 0x01, // bNumInterfaces: 1 interface 0x01, // bConfigurationValue: 1 0x00, // iConfiguration: none 0xA0, // bmAttributes: bus-powered, remote-wakeup 0x32, // MaxPower: 100mA //--------------------------------------------------------------------------------------------------------------------- // INTERFACE DESCRIPTOR //--------------------------------------------------------------------------------------------------------------------- 0x09, // bLength: Size of descriptor 0x04, // bDescriptorType: Interface 0x00, // bInterfaceNumber: #0 0x00, // bAlternateSetting: #0 0x02, // bNumEndpoints: 2 0x03, // bInterfaceClass: HID-class 0x00, // bInterfaceSubClass: none 0x00, // bInterfaceProtocol: none 0x00, // iInterface: none //--------------------------------------------------------------------------------------------------------------------- // HID-CLASS DESCRIPTOR //--------------------------------------------------------------------------------------------------------------------- 0x09, // bLength: Size of descriptor 0x21, // bDescriptorType: HID Class 0x00,0x01, // bcdHID: HID Class version 1.1 0x00, // bCountryCode: none 0x01, // bNumDescriptors: 1 report descp 0x22, // bDescriptorType: report descriptor type REP_LEN,0x00, // wDescriptorLength: 31 bytes //--------------------------------------------------------------------------------------------------------------------- // ENDPOINT1 in DESCRIPTOR //--------------------------------------------------------------------------------------------------------------------- 0x07, // bLength: Size of descriptor 0x05, // bDescriptorType: Endpoint 0x81, // bEndpointAddress: IN, EP1 0x03, // bmAttributes: Interrupt EP1_LEN,0x00, // wMaxPacketSize: 0x0A, // bInterval: 10ms //--------------------------------------------------------------------------------------------------------------------- // ENDPOINT2 out DESCRIPTOR //--------------------------------------------------------------------------------------------------------------------- 0x07, 0x05, 0x02, // bEndpointAddress: out, EP2 0x03, // bmAttributes: Interrupt EP1_LEN,0x00, // wMaxPacketSize: 0x0A // bInterval: 10ms }; //--------------------------------------------------------------------------------------------------------------------- // REPORT DESCRIPTOR //-------------------------------------------------------------------------------------------------------------------------- // Bytes | Bit 7 | Bit 6 | Bit 5 | Bit 4 | Bit 3 | Bit 2 | Bit 1 | Bit 0 | //-------------------------------------------------------------------------------------------------------------------------- // 0 | ScanNT | ScanPT | BassB | Stop | Play | VolDn | VolUp | Mute | << MultiMedia Audio Control //-------------------------------------------------------------------------------------------------------------------------- // 1 | Email | BookM | Refresh | Stop | Forward | Back | Home | Search | << Internet Application Control //-------------------------------------------------------------------------------------------------------------------------- _rom BYTE Rep_Descp[] = { 0x05, 0x0C, // USAGE_PAGE (Consumer Devices) 0x09, 0x01, // USAGE (Consumer Control) 0xA1, 0x01, // COLLECTION (Application) 0x15, 0x00, // LOGICAL_MINIMUM (0) 0x25, 0x01, // LOGICAL_MAXIMUM (1) 0x09, 0xE2, // USAGE (Mute) // MultiMedia Audio Control 0x09, 0xE9, // USAGE (Volume Up) 0x09, 0xEA, // USAGE (Volume Down) 0x09, 0xCD, // USAGE (Play/Pause) 0x09, 0xB7, // USAGE (Stop) 0x09, 0xB6, // USAGE (Scan Previous Track) 0x09, 0xB5, // USAGE (Scan Next Track) 0x09, 0xE5, // USAGE (Bass Boost) 0x0A, 0x21, 0x02, // USAGE (AC Search) // Internet Application Control 0x0A, 0x23, 0x02, // USAGE (AC Home) 0x0A, 0x24, 0x02, // USAGE (AC Back) 0x0A, 0x25, 0x02, // USAGE (AC Forward) 0x0A, 0x26, 0x02, // USAGE (AC Stop) 0x0A, 0x27, 0x02, // USAGE (AC Refresh) 0x0A, 0x2A, 0x02, // USAGE (AC Favorites/Bookmark) 0x0A, 0x8A, 0x01, // USAGE (AL Email Reader) 0x75, 0x01, // REPORT_SIZE (1) 0x95, 0x10, // REPORT_COUNT (16) 0x81, 0x06, // INPUT (Data,Var,Rel,Prf) 0xC0}; // END_COLLECTION |
|
沙发#
发布于:2004-06-29 17:10
没人知道吗,难道
我自己顶!!11 |
|
板凳#
发布于:2004-06-30 09:01
1.你首先看一看你的设备管理器中是否有“人机接口消费控件设备”来确定你的REPORT DESCRIPTOR是否正确。
2。EP1_LEN是多大,为何EP1和EP2是一样的。 3。你能用CREATEFILE得到句柄,但不能用READFILE和WRITEFILE来操作。对一些特殊设备,如KEYBOARD、MOUSE在WIN2K中是不能操作的,因为它已经为OS独占。这样的答复希望你能满意。 |
|
|
地板#
发布于:2004-06-30 09:45
设备管理器出现“USB人体学输入设备”
EP1_LEN、EP2_LEN 大小为16 EP1和EP2不是一样的啊,你没仔细看吧:) EP1是中断IN EP2是中断OUT WIN2K对“人体学输入设备”读可以吗? |
|
地下室#
发布于:2004-06-30 10:08
1。说明你的REPORT没问题。
2。在你的EP2 DESCRIPTOR中写得是EP1的长度。 3。建议你到WIN98去试一下,它不是独占的。 |
|
|
5楼#
发布于:2004-06-30 14:29
大家看看,还有其他可能性吗?
我用DRIVER STUDIO做的驱动 对设备写正确,读不出来,每次读设备时程序就死机了 但是可以对设备写 这又是为什么呢? |
|
6楼#
发布于:2004-07-28 10:33
大家看看,还有其他可能性吗? 你是HID的通用设备吗?如果是不需要驱动了。 使用ReadFile和WriteFile你一次读写多少字节?应该为一个Packet的大小 还有你使用的同步还是异步读写?如果是同步,那么硬件没有数据会死机的,,嘿嘿,使用异步方式试一试。 |
|
|