LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to unreserve DAQmx tasks without restarting DAQ

Hi,


I use DAQmx functions in 2 different languages . C# and LabVIEW. 

 

Definitely it is not possible to have access to the same lines at the same time because the driver is in  use

 

But I was wondering if there is any way to unreserve tasks and give control to the other language without restoring DAQ because I don't want to power off DUTs

 

For example lets say C# uses AI or DIO lines for reading and writing data. Is it possible to unreserve these lines so then LabVIEW can use DAQmx functions to collect data and then again unreserve lines in labVIEW and give control to C#?

 

Thanks

 

0 Kudos
Message 1 of 6
(5,268 Views)

Have you tried the DAQmx Control Task.vi?

 

Ben64

 

daqmx control task.png

Message 2 of 6
(5,242 Views)

Well I haven’t tried this , but do you mean if I unreserve the task in labVIEW then I can use that line in C#

 

For example below , PXI1Slot2/ai0 is used and then I unreserved the line and closed it. Then  Can I create the same channel , open and start it in C# without getting driver  in use error? 

 

123.png

 

Also , I aheva nother question . If I use PXI1Slot2/ai0 in LabVIEW , does it means all the AI channels ( or DIO ports ) are in used ? So then For example I can't have access to  PXI1Slot2/ai1 in C# or MAX at the same time?

0 Kudos
Message 3 of 6
(5,226 Views)

see here for details of how the DAQmx State transitions work

 

Essentially the resourses needed for a Task can only be "Reserved" by 1 Task. If you unreserve a Task another Task that needs the same resource can then reserve those resources. (So, you don't need to "Clear" the Task, Just unreserve the resources the other task needs)

 

With AI all AI channels share some resources, like Clocks and triggers, so you cannot have to have one task with multiple channels.  DIO can usually have a Task per Port.   To directly answer your question: If you have AI0 reserved in LabVIEW no other application can run a task using AI1


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 6
(5,199 Views)

Thaks Jeff


My main problem is how to unreserve a channel in C# and then create the channel again in LabVIEW or vice versa without having resource issue!

 

 

Do you mean if I unreserve the line and even don't clear the task in LabVIEW that resource is available in C# and there will be no error?

 

or Do I need to somehow pass the task reference from LabVIEW to C#  as well?

0 Kudos
Message 5 of 6
(5,183 Views)

There is no reason you cannot create simillar tasks in C and LabVIEW (But you can only reserve the resources in one app at any time)

 

You could even create the task and save it in MAX and use it in any app.

 

If you read the NI DAQmx C Reference Help you'll find

Capture.PNG

 

In essence, Create your Tasks when you init your app to get the task to the verified state (Check for task sanity!) reserve it if you can (Some other program may be using some needed resource) Unreserve it when you are not actively using it (so another App can share resources) and clear it only when your app exits.  

 

THAT being said, if you KNOW, as you do, that you have more that one app that needs access to a given DAQmx resource- put some thought into how to handle errors when Reserve fails.  A user dialog to let them know "Another app is using a resource needed by MyTask - try again after the other app unreserves the resource" and loop gracefully.

 

Or, just don't do that- buy more hardware.Smiley Very Happy (Watch the mega kudos from the NI employees for that!)


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 6
(5,165 Views)