阅读:2249回复:4
【紧急求助】Win2000 DDK问题:如何使用IOCTL_READ_REGISTERS和IOCTL_WRITE_REGISTERS操作USB设备的寄存器?
Win2000 DDK问题:如何使用IOCTL_READ_REGISTERS和IOCTL_WRITE_REGISTERS操作USB设备的寄存器?
我在对USB接口的扫描仪编程。接口芯片为LM9831,使用usbscan.sys作为内核WDM驱动。 关于IO_BLOCK结构的意义我还不甚理解。请各位大侠指教。比如,要想向地址为0x07的寄存器赋值0x20,是这样填写IO_BLOCK吗: UCHAR pbyData[1]; pbyData[0] = 0x20; IoBlock.uOffset = 0x07; IoBlock.uLength = 1; IoBlock.pbyData = pbyData; DDK帮助文档关于IOCTL_WRITE_REGISTERS有如下使用样例: Code Example DWORD cbRet; BOOL bRet; IO_BLOCK IoBlock; OVERLAPPED overlapped; IoBlock.uOffset = (BYTE)byOffset; IoBlock.uLength = (BYTE)byNbOfReg; IoBlock.pbyData = pbyData; memset(&overlapped, 0, sizeof(OVERLAPPED)); overlapped.hEvent = CreateEvent( NULL, // pointer to security attributes // WIN95 ignores this parameter FALSE, // automatic reset FALSE, // initialize to not signaled NULL); // pointer to the event-object name bRet = DeviceIoControl( DeviceHandle, (DWORD) IOCTL_WRITE_REGISTERS, &IoBlock, sizeof(IO_BLOCK), NULL, 0, &cbRet, &overlapped); if( bRet == TRUE ) { WaitForSingleObject(overlapped.hEvent, INFINITE); // we do not the test, the result is zero } CloseHandle(overlapped.hEvent); |
|
沙发#
发布于:2004-05-20 11:45
应该不可以这样操作的
USB驱动中只能通过pipe来通信 寄存器是由firmware来操作的 |
|
板凳#
发布于:2004-05-20 14:02
在2000DDK中对usbscan.sys接口声明如下usbscan.h,
其中的IOCTL_READ_REGISTERS和IOCTL_WRITE_REGISTERS该如何使用呢? /*++ Copyright (C) 1997, Logitech Inc. Module Name: UsbScan.h Abstract: Interface with UsbScan kernel driver Environment: User and kernel mode use Notes: Interface definition for USB still image driver. --*/ …… #define FILE_DEVICE_USB_SCAN 0x8000 #define IOCTL_INDEX 0x0800 #define IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_CANCEL_IO CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+1, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_WAIT_ON_DEVICE_EVENT CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+2, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_READ_REGISTERS CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+3, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_WRITE_REGISTERS CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+4, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_GET_CHANNEL_ALIGN_RQST CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+5, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_GET_DEVICE_DESCRIPTOR CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+6, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_RESET_PIPE CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+7, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_GET_USB_DESCRIPTOR CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+8, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_SEND_USB_REQUEST CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+9, METHOD_BUFFERED,FILE_ANY_ACCESS) #define IOCTL_GET_PIPE_CONFIGURATION CTL_CODE(FILE_DEVICE_USB_SCAN,IOCTL_INDEX+10,METHOD_BUFFERED,FILE_ANY_ACCESS) |
|
地板#
发布于:2004-05-22 10:28
mark
|
|
地下室#
发布于:2004-05-24 10:04
谁有这方面的资料?
|
|