I'm including a snipet from the application. I'm positive the crash occurs somewhere inside the first call to DIG_Change_Message_Config() function. If I step through the code it crashes when I step over that function. If I comment out that function, there is no crash. The parameter seem to be fine to me. It DOES work with those exact same parameters in the Release built. Polling the DIO ports with DIG_In_Port works fine in both Debug and Release.
Thanks again for any help in resolving this matter.
David Cleveland
Research Engineer II
GTRI/ELSYS
void DiscreteChangeCallback()
{
ClDiscreteInputControl* pInst = ClDiscreteInputControl::Instance();
pInst->GetNewDiscreteData();
}
UINT DiscreteThreadFunc(LPVOID pParam)
{
bool bContinue = true;
SuThreadParam* psuParam = (SuThreadParam*) pParam;
static char *chanString = "0.0:7,1.0:7,2.0:7";
ClDiscreteInputControl* pInst = ClDiscreteInputControl::Instance();
CEvent pollDiscretes(FALSE,TRUE);
DWORD dwResult;
const HANDLE ahEvents[] = { (HANDLE)g_clDiscreteStartEvent,
(HANDLE)g_clDiscreteTerminateEvent,
(HANDLE)g_clDiscreteStopEvent,
(HANDLE)pollDiscretes };
const DWORD dwCount = sizeof(ahEvents) / sizeof(HANDLE);
do
{
// wait for start or terminate signal
dwResult = ::WaitForMultipleObjects( dwCount, ahEvents, FALSE, INFINITE );
switch (dwResult)
{
// start event
case WAIT_OBJECT_0:
TRACE("DISCRETE: Start Event\n");
/*
// start change notification
// callback function will execute on any rising or falling edge
// for all input ports (ports 0-2)
DIG_Change_Message_Config(1,1,chanString,chanString,0,0,(u32)DiscreteChangeCallback);
DIG_Change_Message_Control(1,0);
DIG_Change_Message_Config(2,1,chanString,chanString,0,0,(u32)DiscreteChangeCallback);
DIG_Change_Message_Control(2,0);
*/
// start polling
pollDiscretes.SetEvent();
break;
// terminate event
case WAIT_OBJECT_0+1:
TRACE("Discrete: Terminate Event\n");
bContinue=false;
break;
// stop event
case WAIT_OBJECT_0+2:
TRACE("Discrete: Stop Event\n");
/*
// stop change notification
DIG_Change_Message_Config(1,0,NULL,NULL,0,0,0);
DIG_Change_Message_Control(1,1);
DIG_Change_Message_Config(2,0,NULL,NULL,0,0,0);
DIG_Change_Message_Control(2,1);
*/
// stop polling
pollDiscretes.ResetEvent();
break;
case WAIT_OBJECT_0+3:
pInst->GetNewDiscreteData();
break;
}
} while (bContinue);
delete psuParam;
TRACE("Exiting DiscreteThreadFunc\n") ;
return 0;
}