导航: 老古网老古论坛XMOS公共讨论区XMOS开源项目区单片机程序设计嵌入式系统广告区域
→发表看法:[WANGSONGLEI007]硬件:WDM之SOS!!!!!!!



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 ......

>>返回讨论的主题



  发表回复
用户名   *您没有注册?
密码   *
验证码   * .
标题   *
心情
随便说说    我回答你    最新发现    得意的笑   
气死我了    真是没劲    坚决同意    表示反对   
大家过来    好奇怪哟    懒得理它    大家小心   
文件上传
内容


字体:      字体大小:    颜色:
粗体 斜体 下划线 居中 超级连接 Email连接 图片 Flash图片 Shockwave文件 realplay视频文件 Media Player视频文件 QuickTime视频文件 引用 飞行字 移动字 发光字 阴影字 查看更多的心情图标 背景音乐
点击加入表情
                         
选项
有回复时用短消息通知您?

   




老古网执行:29毫秒 最大:7276毫秒 查询6次