01-03-2017 02:42 PM
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
01-03-2017 03:59 PM
Hi,
Here is a version of find open COMS.
Goodluck
01-04-2017 08:28 AM
Thanks very much Matt; I can certainly use this!
01-04-2017 09:35 AM
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?
01-04-2017 09:36 AM
Actually, no it didn't. Although usefule, once I looked more into the code, I realized it didn't do what I wanted...
01-04-2017 09:41 AM - edited 01-04-2017 09:45 AM
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.
01-04-2017 10:01 AM
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?
01-04-2017 10:57 AM - edited 01-04-2017 11:04 AM
Try Open Sessions.vi
C:\<LabVIEW>\vi.lib\Utility\visa.llb\Open Sessions.vi
Note: Does not work in LV 2013 but was fixed in LV 2014. See attached work around for LV2013
01-04-2017 11:12 AM
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.
01-04-2017 11:57 AM
If the port was opened by another application, then you'll get an error if you try to open it in LabVIEW.