From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

error code -200088, accessing DAQmx read function in fncB from fnc A

Hi,
I am using NIDAQ 6229, and C code.
My c code is as follows:
#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }
int main()
{
  TaskHandle aiTaskHandle;
// and the variables whatever used in the API's declaration below done here and initialised
  DAQmxStartTask (aiTaskHandle);
  DAQmxErrChk (DAQmxCreateTask("AI Task",&aiTaskHandle));
  DAQmxErrChk (DAQmxCreateAIVoltageChan(aiTaskHandle,AIChannelList,AINameList,DAQmx_Val_RSE,0.0,10.0,DAQmx_Val_Volts,NULL)); 
  DAQmxCfgSampClkTiming(aiTaskHandle,"OnboardClock",AIRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,AISamplesPerChannelAcq);
  while(1)
  {
            fncB( );
  }
}
 
fncB(  )
{
            DAQmxErrChk (DAQmxReadAnalogF64  
              (AITaskHandle,DAQmx_Val_Auto,timeOut,DAQmx_Val_GroupByScanNumber,AIReadArray,AIarraySizeInSamps,&AISampsPerChanRead,NULL));
}
 
This Code builds without errors and runs. But the problem is with calling the fncB( ) where the DAQmx read for aiTaskHandle is executing.
The DAQ read works fine for one time, but in the second call of fncB it gives error " task specified is invalid or does not exist" with error return code: -200088.
why for the second call , the task specified becoming unknown is not yet all clear.
the ni error codes document doesnot list this error code yet all.
 
i have tried in declaring aiTaskHandle variable global, then in the first time of calling fncB it gives the error as mentioned above.In my application i cant use DAQRead in the same function where i declared the taskHandle , so i have to call it from the function.
Does some body help in calling the DAQread from another function, and why this task is becoming invalid for the second call,.
Thanks ,
vishnu
 
 
 
 
 
 
 
 
 
  
 

Message Edited by gkvishnu on 10-12-2005 08:10 AM

0 Kudos
Message 1 of 4
(3,183 Views)
gkvishnu,
 
Does this error happen if you move your call to DAQmxStartTask to after you are done with your configuration?  Typically, the order of operation for a DAQmx task is:
1) Create a task.
2) Add channels to it
3) Make timing/triggering/buffering configuration settings
4) Start
5) Read (one or multiple times)
6) Clear
 
One thing to check is to ensure that fncB() is neither stopping nor clearing that task.  Both of these operations could result in errors if you were to try to read the task again.
 
Just a couple of ideas,
Dan
0 Kudos
Message 2 of 4
(3,166 Views)
Hello,

I got the same kind of problem.
I get my code from the daqmx examples but i cut it because it is too massive from my application.
I wanted to separate the configuration part of the task but i always got the -200088 error when I wanted to start it somewhere else.

Are all the operations of the task have to be done in the same function?
Can't we create/configure a task in a initialsation part of a program, get the handle and start and use the task anywhere else in the program (the taskHandle still active of course)?

Thanks.


Yop!
DanY


0 Kudos
Message 3 of 4
(3,098 Views)
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
0 Kudos
Message 4 of 4
(3,078 Views)