Hello? I have a couple of questions; DAQmxErrChk functions causes an error I don't get it.
And DAQmxGetDevProductType and DAQmxGetSysDevNames functions work WITHOUT creating a task. The testing MFC program shows PCI-6025E and Dev1. Is this a right way to detect it? Or Do I have to create a task in MAX?
As you see, I commented out some code to find which line makes a problem.
-----------------------------------------------------------------------------------------------------------------------
#include <NIDAQmx.h>
..
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else
..
int CTestDialogClass::FindMyDAQLegacyDevice_With_DAQmx()
{
int32 error=0;
char errBuff[2048]={'\0'};
char devNames[256]={'\0'};
char testDevName[256]={'\0'};
/*********************************************/
// DAQmx Configure Code
/*********************************************/
/* It seems that DAQmxGetDevProductType and
* DAQmxGetSysDevNames functions work w/o
* creating a task.
*/
/* DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxStartTask(taskHandle));
*/
//DAQmxErrChk causes error below.
DAQmxErrChk (DAQmxGetDevProductType("Dev1", testDevName, 256));
DAQmxErrChk (DAQmxGetSysDevNames(devNames,256));
// DAQmxGetDevProductType("Dev1", testDevName, 256);
// DAQmxGetSysDevNames(devNames,256);
/*********************************************/
// DAQmx Start Code
/*********************************************/
m_cstringProductName = testDevName;
m_cstringDeviceName = devNames;
Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
AfxMessageBox("DAQmx Error, DAQmx can't find the device", MB_OK,0);
/* if( taskHandle!= 0 ) {
DAQmx Stop Code
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
} */
return 0;
}
----------------------------------------------------------------------------------------------------------------------
Weird thing is DAQmxErrChk shows an error message but DAQmxGetDevProductType and DAQmxGetSysDevNames return their value.
why DAQmxErrChk can't call a function but the function STILL WORKS?
Thanks,
Message Edited by anarkie on
07-21-2008 08:31 AM
I'm converting DAQ to DAQmx..from Parkoz.com