LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx RegisterEvent error

Solved!
Go to solution

Hi, I have following code:

void SetSingle (TaskHandle AITask)
{
DAQmxCfgSampClkTiming (AITask, "OnboardClock", numberOfSamp*2, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, numberOfSamp);
DAQmxRegisterDoneEvent (AITask, 0, fcn_measure_finite, NULL); 
}

 

for the first time its called its fine, but when I call this again, it gives me this error:

Done Event Registration has failed because event is already register within the task. Unregister the event before registering it again. I searched internet a lot but havent find anything...any ideas how to unregister event? 

Thanks.

0 Kudos
Message 1 of 5
(2,850 Views)

As you can read in the help for the function (DAQmxDoneEventCallbackPtr parameter):

[DAQmxDoneEventCallbackPtr ] Passing NULL for this parameter unregisters the event callback function.

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 5
(2,800 Views)
Solution
Accepted by topic author Adate

Dear Adate,

 

you can unregister the event by passing NULL value to parameter "callbackFunction" of the function "DAQmxRegisterDoneEvent". This information can be found in manual, which is part of CVI or which is available online.

 

DAQmxRegisterDoneEvent

http://zone.ni.com/reference/en-XX/help/370471AE-01/daqmxcfunc/daqmxregisterdoneevent/

 

 

Please let me know, if you will have any further troubles.

Best Regards,

Michal
AE CZ/SK

0 Kudos
Message 3 of 5
(2,799 Views)

dear mjadrny,

thanks for your reply, it helps me solve that problem...however.. another problem showed up 😄

Im building oscilloscope, and for a single measurement I use this code called from RegisterDoneEvent (code below):

 

int32 CVICALLBACK fcn_measure_finite (TaskHandle taskHandle, int32 status, void *callbackData)
{
int samples, buffer;
DAQmxReadAnalogF64 (AI_TaskHandleOSC, DAQmx_Val_Auto, 10.0, DAQmx_Val_GroupByChannel, &data, numOfSamp, &samples, 0);
DAQmxGetReadAttribute (AI_TaskHandleOSC, DAQmx_Read_AvailSampPerChan, &buffer);
DeleteGraphPlot (panelOsc, PANEL_OSC_GRAPH_TIME, -1, VAL_IMMEDIATE_DRAW); 
PlotY (panelOsc, PANEL_OSC_GRAPH_TIME, data, numOfSamp, VAL_DOUBLE, VAL_THIN_LINE, VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
DAQmxStopTask (AI_TaskHandleOSC);
return 0;
}

 

Setting timing and task:

void SetCont (TaskHandle AITask)
{
DAQmxCfgSampClkTiming (AITask, "OnboardClock", numOfSamp*2, DAQmx_Val_Rising, DAQmx_Val_ContSamps, numOfSamp);
DAQmxRegisterEveryNSamplesEvent (AITask, DAQmx_Val_Acquired_Into_Buffer, numOfSamp, 0, fcn_measure_osc, NULL);
}

void SetSingle (TaskHandle AITask)
{
DAQmxCfgSampClkTiming (AITask, "OnboardClock", numOfSamp*2, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, numOfSamp);
DAQmxRegisterDoneEvent (AITask, 0, fcn_measure_finite, NULL);
}

 

When I switched from single measurement to continuous, it fine, but when I switched back to single, it gives me -200278 error. (Attempted to read a sample beyond the final sample acquired....). Every time I switch this I stop task first and then start task.

 

Any advice?

 

Thanks 🙂

0 Kudos
Message 4 of 5
(2,780 Views)

Dear Adate,

 

this behavior is most likely caused by common mistake in architecture of your application. The explanation of this error and possible ways how to remove this error are described in following KB:

 

Why do I get Error -200278 at DAQmx Read VI?

http://digital.ni.com/public.nsf/allkb/4159A4241B8A24B3862570EC007AB6B7?OpenDocument

 

I know, that you are using CVI and not LabVIEW environment, but the structure and commands are the same for both environments. 

 

 

Michal
AE CZ/SK

0 Kudos
Message 5 of 5
(2,758 Views)