06-09-2009 09:56 AM
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.
Is there any function to load all activated or possible task in code and stop/clear them at once?
Regards,
Solved! Go to Solution.
06-10-2009 10:59 AM
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.
06-10-2009 12:42 PM
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