|
各位大哥大姐好,工作就是问题叠问题,小弟我又来了...
开发板上有几个跳线,我写了一个测试的程序,却出问题了,大家帮忙看看...
跳线驱动部分内容:
BOOL Addr_Init()
{
//地址映射
}
BOOL WINAPI DllEntry(HANDLE hInstDll,DWORD dwReason,LPVOID lpvReserved)
{
}
DWORD JMP_Init(DWORD dwContext)
{
Addr_Init();
return 1;
}
DWORD JMP_Deinit(DWORD dwContext)
{
//取消地址映射,释放内存等
}
DWORD JMP_Open(DWORD hDeviceContext,DWORD AccessCode,DWORD ShareMode)
{
//相关引脚的初始化
return 1;
}
BOOL JMP_Close(DWORD hOpenContext)
{
//还原引脚状态
}
BOOL JMP_IOControl(DWORD hOpenContext,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenout,
PDWORD pdwActualOut
)
{
//这个部分返回引脚状态
unsigned int pin = 0;
pin = g_pPIOB->PIO_PDSR & JUMP_MASK;
pin = pin ^ JUMP_MASK;
*((unsigned int *)pBufOut) = pin;
return 1;
}
测试程序部分,一个按钮触发测试,有一个线程调用JMP——IOCtrol检测。如下
void CJump_TestDlg::OnButtontest()
{
// TODO: Add your control notification handler code here
DWORD IDThread;
HANDLE hJumpTestThread;
hJumpTestThread = CreateThread(0,0,Jump_Test_Thread,this,0,&IDThread);
if(hJumpTestThread == NULL)
{
CloseHandle(hFile);
hFile = NULL;
return ;
}
else
CloseHandle(hJumpTestThread);
}
DWORD CJump_TestDlg::Jump_Test_Thread(PVOID pArg)
{
CString strCount;
static unsigned int flag = 0xff;
unsigned long Size =0;
unsigned int Jump = 0;
CJump_TestDlg *pDlg = (CJump_TestDlg *)pArg;
CStatic * pTestStatic = (CStatic *)pDlg ->GetDlgItem(IDC_STATIC_RESULT);
while(1)
{ //KillProc =0的话,进程就执行,否则退出
if(KillProc == 0)
{
DeviceIoControl(hFile,0,NULL,0,&Jump,sizeof(unsigned int),&Size,NULL);
//执行显示操作
}
else if(KillProc == 1)
return 0;
}
return 1;
}
关闭测试按钮的代码如下;
void CJump_TestDlg::OnButtonclose()
{
// TODO: Add your control notification handler code here
if(hFile)
{
KillProc = 1;
CloseHandle(hFile);
hFile = NULL;
MessageBox(_T("关闭JMP"));
}
}
现象如下:从开始测试,到测试过程中,一点问题没有,好的很,但是当我点关闭测试按钮的时候,系统就没有反应了。
我想可能是存在什么死循环或者没有释放什么资源,但是我仔细看了好几遍代码,也没有得出什么结论,贴上来,让大家帮忙,谢谢了
在线等...
|
|