Discussion:
Closing Identical VISA Sessions
(too old to reply)
DJDDA
2008-08-11 20:40:06 UTC
Permalink
I have several sub VI's using VISA in my latest build.  By default they all use the same VISA session, but the user has the option to switch one or more sub VI's to a different device (different VISA session). In my "Panel Close" event, I currently have it wired such that each sub VI's VISA session is closed separately.  It occurred to me that this may cause problems in the (normal) case that one or more sub VI's is using the same session; however, my main VI is somewhat of a mess, and it will be a couple days before I can actually test this.Will it cause errors, program crashing, etc. for me to give a Close command on a VISA session that isn't open any more?
MikeS81
2008-08-12 07:10:05 UTC
Permalink
Hi DJDDA,
if you use different VISA sessions, you should store these references in a shift register. Use a for loop to close all opened references. You can also check if a VISA session is already closed before you try to close it again.
 
Hope it helps.Mike
smercurio_fc
2008-08-12 15:40:27 UTC
Permalink
DJDDA wrote:Will it cause errors, program crashing, etc. for me to give a Close command on a VISA session that isn't open any more?In a word: no.
Sarah_S
2008-08-12 16:10:12 UTC
Permalink
Hey DJDDA, I have tested out the setup of closing a session after it was previously closed. There are not any errors produced and it will not crash your program. You are able to close a session as many times as you want. The problem you might run into is if you close the session before an alternate subVI is done using that. That will cause problems in your program.ThanksSarah_S
DJDDA
2008-08-12 18:40:06 UTC
Permalink
MikeS81: That's a good idea, I suppose, but it would require more modification of my functional global than I'm in the mood for right now; I'd prefer to just throw in an Undbundle By Name with a Close VISA for each subVI.  I just wanted to make sure it would be possible to do it this way.Sarah_S: Thanks for the heads-up about closing sessions in use by other subVI's.  That saved me some trouble.
Loading...