NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How To Release a VISA resource opened in Teststand with LabView VI

Solved!
Go to solution
Highlighted

I have a very easy question(hopefully) but it is driving me crazy.  How do I close a VISA resource in teststand?

 

I am opening a serial communication session to the COM port using:

C:\Program Files (x86)\National Instruments\LabVIEW 2013\vi.lib\Instr\_visa.llb\VISA Configure Serial Port (Instr).vi

called from an action steptype to a "VI Call"

The session opens ok and populates a LabVIEWIOControl container of

Device Name = "COM4" {this is loaded by me for input to the VI and is the Alias name of the VISA resource}

Session Number = { here it is a fileglobal variable and the vi populates it with a big number like 270508088 }

 

but when the test sequence is stopped and restarted it fails to open.  Also the NIMAX gives the following on the VISA test panel:

VISA:  (Hex 0xBFFF0072) The resource is valid, but VISA cannot currently access it.

 

I know teststand is holding the COM port VISA resource but i don't know how to make it let go.

 

The only way to recover is to completely exit teststand and restart.  "unload all modules" does not even work.

 

The vi "_visa.llb" does not have a Close VI Call. and i don't know how to "kill or terminate or release" an active session even though i have the session number.

 

0 Kudos
Message 1 of 9
(2,261 Views)

Try to Create a Separate driver for VISA Control (Open, Read, Write and Close) functions in a single run while loop where shift register holds the VISA Reference.

Once the VISA Communication is completed just Close the VISA Port Before Coming out of Sequence.

Palanivel Thiruvenkadam,
CLA|| CTD
0 Kudos
Message 2 of 9
(2,243 Views)

Thanks for the response.  I have used the technique in the past with CVI drivers but here it is not pratical because i am using a 3rd software set the needs the VISA resource.  So i need to open the VISA and pass it to the 3rd party software to create an object pointer to the resource (a device attached to the Comm Port).  it would be very time consuming to create new instances of the object everytime i needed to access it.  Note: i do release the 3rd party resource object pointer at the end by assigning it to "Nothing" but it doesn't release the VISA resource.

0 Kudos
Message 3 of 9
(2,235 Views)

@mbstratton wrote:

Thanks for the response.  I have used the technique in the past with CVI drivers but here it is not pratical because i am using a 3rd software set the needs the VISA resource.  So i need to open the VISA and pass it to the 3rd party software to create an object pointer to the resource (a device attached to the Comm Port).  it would be very time consuming to create new instances of the object everytime i needed to access it.  Note: i do release the 3rd party resource object pointer at the end by assigning it to "Nothing" but it doesn't release the VISA resource.


Not sure about CVI!

 

But in LabVIEW its quite possible to achieve your requirement as suggested above!

Palanivel Thiruvenkadam,
CLA|| CTD
0 Kudos
Message 4 of 9
(2,230 Views)
Solution
Accepted by topic author mbstratton

mbstratton-

 

What is the behavior that occurs as a result of your previous statement: 'but when the test sequence is stopped and restarted it fails to open.'? Do your VI return the same error as is displayed by NI MAX?

 

I am also curious if the Session Number you are passing to the VI call that is opening the VISA session is something other than 0? As you can see in the following link: http://digital.ni.com/public.nsf/allkb/6FA2495A26DCD40086257A01006A80A9?OpenDocument, you should expect to see an error if you pass a non-zero value for the Session Number of the Visa Resource Name parameter of your VI input. Should you need to pass a reference to the VISA session between steps in your Sequence, see the linked KnowledgeBase for that information as well.

 

-Jeff

Message 5 of 9
(2,218 Views)
Can you attach the file for reference? So that it will be more explanatory.
Palanivel Thiruvenkadam,
CLA|| CTD
0 Kudos
Message 6 of 9
(2,215 Views)

thank-you, the link is very good because I was getting confused on the session number on whether I assign it and it is assigned. Tha is exactly how i was handleing the variable with a passed in constant of 0 and the passed back structure of LabVIEWIOControl being used to pass the VISA to following test steps.

So that all works good but still remains that i am unable to close the session.  Maybe it is not a big thing because re-running the sequence within Teststand does work and actually re-opens the same VISA session.

In other words:

Run Number #1
Visa Resource name
 Device Name = "COM4"
 Session Number = 270508088

Thread completes and stopped, Unload all modules clicked from the File pulldown and then test sequence restarted and the same session opens back up.
Visa Resource name
 Device Name = "COM4"
 Session Number = 270508088

Note: in reality it never closed becuase no outside program will be able to access COM4 until the Teststant environment is exited.

I did see that there is a control within labview called "Visa Close Function" in the Owning Pallette of VISA Advanced VIs and Functions.  I am not able to find this call as a .vi that can be call from teststand.  I guess i could just create i small .vi that only calls this one control to release the resource. 

The big thing is that I was afraid i was creating new sessions and creating a memory leak since the resource was never being closed between executions.  That is not the case since it just re-establishes to the old session.

Does anybody know if "Visa Close Function" already exists somewhere as a .vi that can be called from Teststand?

0 Kudos
Message 7 of 9
(2,168 Views)

You juste have to create that VI and call it from a LabVIEW step action.

0 Kudos
Message 8 of 9
(2,152 Views)
You Need to create a vi in which close visa can be called and the reference of visa needs to be passed to close opened visa reference.
Palanivel Thiruvenkadam,
CLA|| CTD
0 Kudos
Message 9 of 9
(2,139 Views)