04-17-2017 11:08 AM
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.
Solved! Go to Solution.
04-18-2017 01:40 AM
As you can read in the help for the function (DAQmxDoneEventCallbackPtr parameter):
[DAQmxDoneEventCallbackPtr ] Passing NULL for this parameter unregisters the event callback function.
04-18-2017 02:11 AM
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
04-19-2017 12:00 PM
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 🙂
04-20-2017 08:22 AM
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