Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxErrChk Error

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.
 
Looks like DAQmxErrChk code is not working. I copied DAQmxErrChk code from NI help http://zone.ni.com/devzone/cda/tut/p/id/5959
 
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
0 Kudos
Message 1 of 2
(6,587 Views)

Hi anarkie,

Yes, you can retrieve the information of your device using the functions: DAQmxGetDevProductType and DAQmxGetSysDevNames. This information is not related to a specific task, I understand that’s why you don’t need to have a task in order to retrieve this information. The information is being retrieved from the device but is not associated to a specific task. I would also suggest looking onto the shipping examples when you start developing your application. There are many examples that can serve as a starting point for your application. The examples can be found here: …\Documents and Settings\All Users\Documents\National Instruments\NI-DAQ\Examples. I hope this is helpful,

Ana P
National Instruments
Applications Engineer
0 Kudos
Message 2 of 2
(6,565 Views)