I am following this example code, ContGen-IntClk.c.
#include <NIDAQmx.h>
#include <stdio.h>
#include <math.h>
#define DAQmxErrChk (functionCall) if( DAQmxFailed(error = (functionCall)) ) goto Error; else
#define PI 3.1415926535
#define DAQmxFailed(error) ((error)<0)
int32 CVICALLBACK DoneCallback (TaskHandle taskHandle, int32 status, void *callbackData);
int main(void)
{
int32 error = 0;
TaskHandle taskHandle = 0;
float64 data [1000];
char errBuff [2048] = {'\0'};
int i = 0;
for (; i < 1000; i++) data [i] = 9.95 * sin( (double) i * 2.0 * PI / 1000.0);
/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask ("",&taskHandle) );
DAQmxErrChk (DAQmxCreateAOVoltageChan (taskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL) );
DAQmxErrChk (DAQmxCfgSampClkTiming (taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000) );
DAQmxErrChk (DAQmxRegisterDoneEvent (taskHandle,0,DoneCallback,NULL) );
/*********************************************/
// DAQmx Write Code
/*********************************************/
DAQmxErrChk (DAQmxWriteAnalogF64 (taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL) );
/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));
printf ("Generating voltage continuously. Press Enter to interrupt\n");
getchar ();
Error:
if ( DAQmxFailed (error) )
DAQmxGetExtendedErrorInfo (errBuff,2048);
if ( taskHandle != 0 )
{
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask (taskHandle);
DAQmxClearTask (taskHandle);
}
if ( DAQmxFailed(error) )
printf ("DAQmx Error: %s\n",errBuff);
printf ("End of program, press Enter key to quit\n");
getchar ();
return 0;
}
int32 CVICALLBACK DoneCallback (TaskHandle taskHandle, int32 status, void *callbackData)
{
int32 error = 0;
char errBuff [2048] = {'\0'};
// Check to see if an error stopped the task.
DAQmxErrChk (status);
Error:
if( DAQmxFailed (error) )
{
DAQmxGetExtendedErrorInfo (errBuff,2048);
DAQmxClearTask (taskHandle);
printf ("DAQmx Error: %s\n", errBuff);
}
return 0;
}
I would like to ask what generates the call to DoneCallback() function. Thanks.