LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmx Tasks and Channels

Solved!
Go to solution

Greetings,

In order to write a digital output point in DAQmx, I use DAQmxCreateTask to first create a task, then DAQmxCreateDOChan to create the channel.

I'm working in exception handling as much as possible, and have a need to test a Task for whether it contains any Channels or not.

 

I have the DAQmxCreateTask and DAQmxCreateDOChan in a block that break statements will terminate. If the create task isn't successful, I log an error and break out of the block. If it is successful, I proceed to creating a task. If this is not successful, I again break out of the block and proceed to shutting down the program.

 

In the code that shuts down the program, I have a line that writes to a digital point in this Task and channel. But I need to be able to NOT write the point if the creation of the channel was not successful.

 

I can test my TaskHandle to see if the task was created, but if it was, how do I test the TaskHandle to see if a channel was created or not?

 

(It throws another error in the shutdown when writing the digital point if the channel failed to create, so I need to not write the point if the channel was not created. How can I tell?)

 

Thanks!

0 Kudos
Message 1 of 4
(2,270 Views)

LabVIEW has a property node for DAQmx Task that can query for the channels contained in the task and the number of channels. There should be something similar in CVI too.

 

santo_13_0-1637385836396.png

 

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 4
(2,266 Views)
Solution
Accepted by topic author LelandDurrette

Indeed there is!

 

This instruction will return the number of channels in the task, which in your case can be enough:

DAQmxGetTaskAttribute (..., DAQmx_Task_NumChans, &nchan, ...);

 

You can additionally call the same function with DAQmx_Task_Channels attribute to retrieve the name of the channels in the task.



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?
Message 3 of 4
(2,229 Views)

Thanks! I blindly looked and didn't find anything. My solution was to put a wrapper around the handle that included a Boolean flag I would set when the Channel was created. Works, but I like this approach much better!

0 Kudos
Message 4 of 4
(2,181 Views)