Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ_Clear for DAQmx

Solved!
Go to solution

Hello?

 

I work on converting DAQ to DAQmx code. As we know DAQ_Clear can be ported to DAQmxStopTask/DAQmxClearTask in DAQmx. But question is, is there any way to stop all loaded task at once in DAQmx?

 

DAQ_Clear code does it. It stops all activities at once. So I used this function whenever I expect an error could be coming. But in DAQmx, I should call each individual task names and write very long codes like:

 

DAQmxStopTask(Task1);

DAQmxStopTask(Task2);

DAQmxStopTask(Task3);

DAQmxStopTask(Task4);

DAQmxStopTask(Task5);

 

...

DAQmxStopTask(Taskn);

DAQmxClearTask(Task1);

DAQmxClearTask(Task2);

DAQmxClearTask(Task3);

DAQmxClearTask(Task4);

DAQmxClearTask(Task5);

 

....

DAQmxClearTask(Taskn);

 

This is not an efficient way to stop/clear tasks. Smiley Sad

Is there any function to load all activated or possible task in code and stop/clear them at once?

 

Regards,

 

 

I'm converting DAQ to DAQmx..from Parkoz.com
0 Kudos
Message 1 of 3
(3,439 Views)

Looking at the help for DAQclear it looks like you pass a reference to the device and it aborts all tasks and all routes. 

 

You have two options. Call the DAQmx Clear/stop functions inside of a for loop and iterate throught he task names.  this would reduce the amount of code used.  the second is to use The DAQmxResetDevice function which aborts all tasks and resets the device to an initial state.  Note that this will also remove any DAQmx Connections you have made.

 

 

Charley Dahan

Global Account Manager
0 Kudos
Message 2 of 3
(3,417 Views)
Solution
Accepted by topic author anarkie

In addition to Charles's answer, please also note that DAQmxResetDevice() will abort any tasks that are running on the specified device, but it will not deallocate the memory used by those tasks. With the DAQmx ANSI C API, applications are responsible for calling DAQmxClearTask() to clear each task that was created using DAQmxCreateTask(). This is analogous to C stdio, where applications are responsible for calling fclose() to close each file that was opened using fopen().

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 3 of 3
(3,410 Views)