阅读:1073回复:2
编译
各位大虾:
我用ds编写了一wdm驱动程序,在win98下用checked编译连接成功,并且上层程序能正确调用,但用free编译也连接成功,上层程序 调用后(打开成功),deviceiocontrol(..)不能返回值. 帮忙解决! |
|
沙发#
发布于:2003-06-25 10:43
看看你驱动中处理 deviceiocontrol 的代码。
|
|
|
板凳#
发布于:2003-06-25 12:30
NTSTATUS PIDSDevice::DeviceControl(KIrp I) { NTSTATUS status; t << \"Entering PIDSDevice::Device Control, \" << I << EOL; //////////////////////////我的代码//////////////////////////////////////// ioBuffer = I.IoctlBuffer(); ULONG ioInSize = I.IoctlInputBufferSize(); ULONG ioOutSize = I.IoctlOutputBufferSize(); I.Information() = 0; switch (I.IoctlCode()) { case DIOC_OPEN://打开WDM命令,对应CreatFile break; case BA_PORTA://卡初始化命令 设置并口地址 t << \"deviceiocontrol te BA_PORTA \"<<EOL; ii=(short int *)ioBuffer;// i1=(short int *)ioBuffer;//返回成功与否信息 hd.PORTA=*ii; *i1=hd.PORTA; I.Information() = sizeof(short int); break; case BA_INIT://卡初始化命令 i1=(short int *)ioBuffer;//返回成功与否信息 *i1=hd.InitCard(); // m_IoPortRangeTest.outb(0x61,0x00);//测试语句 I.Information() = sizeof(short int); break; case BA_RUN: t << \"deviceiocontrol BA_RUN \"<< EOL; i=(short int *)ioBuffer;//输入隔点取数 hd.StartSample(i); I.Information()=0; break; case BA_STOP://结束采样命令 t << \"deviceiocontrol BA_STOP \"<< EOL; hd.StopSample(); break; case BA_TRIG_MODE://设置触发模式命令 t << \"deviceiocontrol BA_TRIG_MODE \"<< EOL; c=(char *)ioBuffer;//输入触发模式 c1=(char *)ioBuffer;//返回有效正确的触发模式 *c1=hd.SetTrigMode(*c); I.Information()=sizeof(char); break; case BA_TRIG_CH://设置触发通道命令 i=(short int *)ioBuffer;//输入触发通道 i1=(short int *)ioBuffer;//返回有效正确的触发通道 *i1=hd.SetTrigCH(*i); I.Information()=sizeof(short int); break; case BA_TRIG_LEVEL://设置触发电平命令 f=(float *)ioBuffer;//输入触发电平 f1=(float *)ioBuffer;//返回有效正确的触发电平 *f1=hd.SetTrigLevel(*f); I.Information()=sizeof(float); break; case BA_SAM_RATE://设置采样速率命令 i=(short int *)ioBuffer;//输入采样速率 i1=(short int *)ioBuffer;//返回有效正确的采样速率 *i1=hd.SetSampleFreCoefficent(*i); I.Information()=sizeof(short int); break; case BA_SAM_CH_ARRAY://设置采样通道命令 i=(short int *)ioBuffer;//输入采样通道阵列 i1=(short int *)ioBuffer;//返回有效的采样通道数 *i1=hd.SetSampleChannelArray(i); I.Information()=sizeof(short int); break; case BA_SAM_CH_AMP://设置量程命令 i=(short int *)ioBuffer;//输入量程 i1=(short int *)ioBuffer;//返回有效量程 *i1=hd.SetAmplifier(i); I.Information()=sizeof(short int); break; case BA_SAM_LEN_PER_CH://设置每个通道采样点数命令 break; case BA_READ_STATUS://读设备状态命令 DeviceStatus=(long int *)ioBuffer;//返回设备状态 hd.ReadDeviceStatus(DeviceStatus); I.Information()=sizeof(long int); break; case BA_READ_DATA://读采样数据命令 { incan=(long int *)ioBuffer;//输入欲读取每通道采样点数,缓冲区最大长度 dat=(short int *)ioBuffer;//返回数据 //num=(long int *)pDIOCParams->dioc_bytesret;//返回真正读取的有效每通道点数 hd.ReadSampleDataFromMemory(incan,dat,num); I.Information()=(*num)*2;//返回真正读取的有效每通道点数 } break; default: // Unrecognized IOCTL request status = STATUS_INVALID_PARAMETER; break; } // If the IRP was queued, or its IOCTL handler deferred processing using some // driver specific scheme, the status variable is set to STATUS_PENDING. // In this case we simply return that status, and the IRP will be completed // later. Otherwise, complete the IRP using the status returned by the // IOCTL handler. if (status == STATUS_PENDING) { return status; } else { return I.PnpComplete(this, status); } } |
|