11-18-2010 05:43 PM - edited 11-18-2010 05:45 PM
Maybe this is a stupid questions but I can't seem to find out how to tell if a VISA session was already opened. Any ideas?
Basically in my SubVI:
Check Validity
If Valid
-Write value to VISA Write
If Not Valid
-Open Session
-Write value to VISA Write
-Close Session
I need to return the opened session to TestStand or calling VI if it was valid before the VI was called. Otherwise I cannot close it because that wold screw up the caller.
Thanks,
Solved! Go to Solution.
11-18-2010 08:58 PM
Do you really care if the session was opened already. It has been years (LabVIEW 6.1?) since you needed to use the VISA Open. If a session is not open, one will be created when you use any VISA function. And if you do call VISA Open and a session has already been created, the existing one will be used unless you explicitly ask for a new one.
11-18-2010 10:51 PM
Thanks for the response Dennis!
I don't really care about the open as much as I do the close. I wanted to check and see if the session was opened when the VI was called so that I can close it before returning to the caller. This VI will be used by many developers and I just wanted built in cleanup as to avoid loose sessions all over. However, if they had already opened a session I don't want to kill it because they may need it elsewhere in their app.
I guess to your point it doesn't matter if I close the session because when they go to do a read or write it will still just open the session again? Let's say I use it in TestStand and a developer opens a session at the beginning. Then they call my VI and it closes the session. Then they try to call another VISA read or write using that handle they opened at the beginning. Will it still work? I thought it was a pointer to some memory location and if you closed it then you can't really use that again unless you create a new session?
I guess I can just put in the description that they must close the session elsewhere in their code regardless of if they use the serial option or not.
11-18-2010 10:59 PM
I'll have to think about the consequences if you are passing the reference around in TestStand. What I do is pass the VISA Resource Name into each VI. Don't pass anything out
11-19-2010 05:15 PM
11-19-2010 10:18 PM
That sucks for people without TestStand but it works for me.
Thanks Glenn!
03-19-2013 10:00 AM
@~jiggawax~ wrote:
That sucks for people without TestStand but it works for me.
Thanks Glenn!
Sorry for digging up an old thread but for those people without TestStand:
"Refnum to Session" is used in visa probes which can be found in the VisaProbes.llb ("\Program Files\National Instruments\LabVIEW 2009\vi.lib\_probes\default\VisaProbes.llb") simply open the "VisaProbeSerialInstr.vi" and copy the subvi from there.
03-20-2015 09:15 AM
@WatWork wrote:
Sorry for digging up an old thread but for those people without TestStand:
"Refnum to Session" is used in visa probes which can be found in the VisaProbes.llb ("\Program Files\National Instruments\LabVIEW 2009\vi.lib\_probes\default\VisaProbes.llb") simply open the "VisaProbeSerialInstr.vi" and copy the subvi from there.
There doesn't seem to be a subvi there anymore if opening with 2014x64 Any other ideas about how to find out if the port is open or not?
03-23-2015 05:57 PM
This Knowledge Base article shows how to identify open VISA Sessions:
http://digital.ni.com/public.nsf/allkb/6A9B4BA95EFA6C22862575080064D98F