I found where does my error come from.
I configure my task from a other function and call this callback to start acquisition (get partly from NI examples)
I get the error on the Start_AI_Clk(taskAIClk); call.
int CVICALLBACK AI_TrigStartCallback(int panel, int control, int event, void *callbackData, int eventData1, int eventData2)
{
int32 error=0;
char Chaine[500],Chaine1[500],ChaineFormateur[500];
int32 numRead;
float64 *data=NULL,*dataMoy=NULL;
int i,j,Checked;
double LocValeurLue,TempsDebut,TempsTotal,TempsEnCours;
long int NbMesTotale = 0;
FILE *TempFile;
if( event==EVENT_COMMIT ) {
if( (data=malloc(NbMes*NbChanAIClk*sizeof(float64)))==NULL ) {
MessagePopup("Error","Not enough memory");
goto Error;
}
TempsDebut = Timer();
TempsTotal = TempsDebut;
TempFile = fopen("TempoResult.txt","w");
Start_AI_Clk(taskAIClk);
ProcessDrawEvents();
gRunningTrig = 1;
while( gRunningTrig )
{
DAQmxErrChk
(Read_AI_Clk(taskAIClk,NbMes,data,NbMes*NbChanAIClk,&numRead));
ProcessSystemEvents();
/*data treatment*/
}
TempsTotal = Timer() - TempsTotal;
fprintf(TempFile,"Temps total:%.3f - Nb Mes totales : %d",TempsTotal,NbMesTotale);
fclose(TempFile);
}
Error:
if( DAQmxFailed(error) )
TraitErreurCarteDAQmx("Lecture AI horloge externe",error);
if( taskAIClk!=0 ) {
Stop_AI_Clk(taskAIClk);
}
if( data )
free(data);
return 0;
}
What happen is when I click on my start button, my function is executed
once before a EVENT_COMMIT came, so it jumps directly to the Error part,
then as the taskHandle is not null, it stop the task
if( taskAIClk!=0 ) {
Stop_AI_Clk(taskAIClk);
Then it executes the if(event==EVENT_COMMIT) part and as the task has been stopped, it give the -200088 error code.
To correct this, I change the Error treatment like this:
if( DAQmxFailed(error) )
{
TraitErreurCarteDAQmx("Lecture AI horloge externe",error);
Stop_AI_Clk(taskAIClk);
}
Yop!
DanY