LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Check is a visa is already opened

Hello everyone,

 

I am using LabVIEW 2015, and I am trying to see if there is any function that can tell me if a visa has already been opened. I did search around for this and it appears there is a vi if you already have TestStand, but is there an easy way to do this if you do not have that?  I also read about an Open Session.vi that returns an array of all the opened visas, but I can't seem to find that either.

 

Thanks, Natalie

0 Kudos
Message 1 of 12
(6,335 Views)

Hi,

 

Here is a version of find open COMS. 

 

Find Open COMS.png

 

Goodluck



-Matt
0 Kudos
Message 2 of 12
(6,291 Views)

Thanks very much Matt; I can certainly use this!

0 Kudos
Message 3 of 12
(6,251 Views)

Does that solution actually answer your question, though? I thought you wanted to detect whether a VISA resource had been opened, but that solution just returns a list of VISA resources with "COM" in the description, presumably serial ports, regardless of whether they have been opened or not, right?

0 Kudos
Message 4 of 12
(6,242 Views)

Actually, no it didn't.  Although usefule, once I looked more into the code, I realized it didn't do what I wanted...

0 Kudos
Message 5 of 12
(6,240 Views)

I just noticed after I posted that it doesn't even look for "COM" in the description, despite what the comment on the code says. It just finds every INSTR resource, tries to open it, and if the open fails it adds it to an array. But a resource that's already opened should return no error just like an unopened one would.

0 Kudos
Message 6 of 12
(6,237 Views)

Question.  Why do you need to know which com ports are already open?

 

Instead of trying to run a query to determine which are open and which aren't, why not keep track of that yourselfl, perhaps with a functional global variable that stores a list of open ports and is called each time a port is open or closed?

 

0 Kudos
Message 7 of 12
(6,226 Views)

Try Open Sessions.vi

C:\<LabVIEW>\vi.lib\Utility\visa.llb\Open Sessions.vi

OpenSessions.png

Note: Does not work in LV 2013 but was fixed in LV 2014. See attached work around for LV2013

Omar
0 Kudos
Message 8 of 12
(6,211 Views)

Ravensfan,

i agree you should keep track of it yourself, and i dont know that this is the problem, but what if a port is opened by another application.

 

Natalie,

I attached the vi's you were looking for and a link for information. You can use the open sessions vi provided by NI to list the open visa sessions.

 

visa session monitoring



-Matt
0 Kudos
Message 9 of 12
(6,208 Views)

If the port was opened by another application, then you'll get an error if you try to open it in LabVIEW.

0 Kudos
Message 10 of 12
(6,199 Views)