阅读:779回复:2
再问一个问题!
就是<<Windows WDM 设备驱动开指南>>中代人例子USBKBD
为什么不能读到HID 描述符呢,我跟踪发现是 驱动有问题, 返的数据的长度为零,其原码如下: NTSTATUS UsbGetSpecifiedDescriptor( IN PUSBKBD_DEVICE_EXTENSION dx, OUT PVOID& Descriptor, IN UCHAR DescriptorType, IN OUT ULONG& Size) { // Allocate memory for URB USHORT UrbSize = sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST); PURB urb = (PURB)ExAllocatePool(NonPagedPool, UrbSize); if( urb==NULL) { DebugPrintMsg(\"No URB memory\"); return STATUS_INSUFFICIENT_RESOURCES; } // Allocate memory for descriptor Descriptor = ExAllocatePool(NonPagedPool, Size); if( Descriptor==NULL) { ExFreePool(urb); DebugPrintMsg(\"No descriptor memory\"); return STATUS_INSUFFICIENT_RESOURCES; } // Build the Get Descriptor URB UsbBuildGetDescriptorRequest( urb, UrbSize, DescriptorType, 0, 0, // Types, Index & LanguageId Descriptor, NULL, Size, // Transfer buffer NULL); // Link URB // Call the USB driver DebugPrint(\"Getting descriptor type %2x\", DescriptorType); NTSTATUS status = CallUSBDI( dx, urb); // Check statuses if( !NT_SUCCESS(status) || !USBD_SUCCESS( urb->UrbHeader.Status)) { DebugPrint(\"status %x URB status %x\", status, urb->UrbHeader.Status); status = STATUS_UNSUCCESSFUL; } Size = urb->UrbControlDescriptorRequest.TransferBufferLength; ExFreePool(urb); return status; } |
|
沙发#
发布于:2002-11-13 10:10
问题找个了,是和USB的版本有关,测试程序的没有正确发送给驱动数据的长度,
// Get HID Report descriptor // Size of HID report is usually in second last byte of //above descriptors 将 ULONG Size = descriptors[BytesReturned-2]; 改为ULONG Size = descriptors[BytesReturned-9]; 可以了.这是在2000下运行的,在98下不要改! 谢谢ydyuse的回答! |
|
板凳#
发布于:2002-11-13 09:39
我原来测试好象无问题,测试时你有USB键盘吗?
|
|
|