No.16043 作者:WANGSONGLEI007 邮件: ID:7655 登陆:1次 文章数:1篇 最后登陆IP: 最后登陆:2002/12/19 9:24:00 注册:2002/12/19 9:24:00 财富:6 发帖时间:2002/12/19 9:38:00 发贴者IP:202.194.201.50 标题:WANGSONGLEI007:硬件:WDM之SOS!!!!!!! 摘要:No.16043硬件:WDM之SOS!!!!!!! 本人在WIN98下按照DriverWizard生成一个基于ISA的WDM,选择基于ISA总线并选择了一个 I/O端口进行读写,其余均默认设置,并生成测试程序,生成的INF文件改I/O端口为0310, 想对此端口写操作。添加设备并重启机器后,查看系统属性设备资源正确,运行测试程序, 程序提示“Device found,Handle Open”但对端口写1个数据时,却不能写入并提示“0 BYTE WRITEN ON THE DEVICE(1 ATTEMPT)” 以下为测试程序代码(由DRIVER WIZARD 自动生成) #include <stdlib.h> #include <stdio.h> #include <windows.h> #include "..\CANISADeviceinterface.h" // Has class GUID definition // This function is found in module OpenByIntf.cpp HANDLE OpenByInterface(GUID* pClassGuid, DWORD instance, PDWORD pError); typedef void VOIDFUNC(); // Prototypes void Usage(void); void CloseIfOpen(void); void doRead(int i); void doWrite(int i); // Global data // Handle to device opened in driver. // HANDLE hDevice = INVALID_HANDLE_value; // Class GUID used to open device // GUID ClassGuid = CANISADevice_CLASS_GUID; //////////////////////////////////////////////////////////////////////// // Exit // // Print a message and exit // void Exit(int res) { printf("Exiting...\n\n"); CloseIfOpen(); exit(res); } //////////////////////////////////////////////////////////////////////// // Main entry point // // int __cdecl main(int argc, char *argv[]) { int nArgIndex; // Walk through command line arguments int nArgIncrement = 0; int val; DWORD Error; printf("Test application Test_CANISA starting...\n"); hDevice = OpenByInterface( &ClassGuid, 0, &Error); if (hDevice == INVALID_HANDLE_value) { printf("ERROR opening device: (%0x) returned from CreateFile\n", GetLastError ()); Exit(1); } else { printf("Device found, handle open.\n"); } // Parse the command line if (argc < 2) Usage(); nArgIndex = 1; while (nArgIndex < argc) { // Parse ahead to determine numeric value of argument if (nArgIndex+1 >= argc) Usage(); if (!isdigit(argv[nArgIndex+1][0])) Usage(); val = atoi(argv[nArgIndex+1]); switch (argv[nArgIndex][0]) { case 'r': case 'R': doRead(val); nArgIncrement = 2; break; case 'w': case 'W': doWrite(val); nArgIncrement = 2; break; case 'i': case 'I': printf("No IO Control Codes defined\n"); Exit(1); case '?': case 'h': default: Usage(); } nArgIndex += nArgIncrement; } return 0; } //////////////////////////////////////////////////////////////////////// // CloseIfOpen // // Close the device if we previously opened a handle to it. // void CloseIfOpen(void) { if (hDevice != INVALID_HANDLE_value) { // Close the handle to the driver if (!CloseHandle(hDevice)) { printf("ERROR: CloseHandle returns %0x.\n", GetLastError()); } hDevice = INVAL ......
>>返回讨论的主题
|