LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Getting an error when closing a VISA session

Solved!
Go to solution

Hi,

I'm getting the exact same error described in this message (VISA close -1073807338) BUT I'm using the latest VISA driver.  My problem is as follows:  I have a main application that is calling other VI's.  This is being done on a test system and the VI's being called are front panels for all the instruments being controlled.  I have two agilent power supplies being control through GPIB using VISA sessions.  The vi's that I'm calling to do this are exactly the same except for the parameters and voltage limits being passed in.  I'm using the open vi session and the run vi method to bring up the front panels and control the supplies but when I tried to exit either instrument's front panel I get the VISA close error. The error happens inside the power supply VI being close.  I don't get it all the time but most of the time it happens.  This is happening in the development environment and I'm afraid this will crash the entire app when I build the executable.  I have another instrument up (serial interface) and I can control and close it OK.  The problem is only with the identical power supply controls.  I'm using the agilent AGE363X LV drivers.  .  I don't know what I'm doing wrong.  The sessions should be independent since I'm specifying a different resource name for each but somehow the VIs are getting confused.  Does anyone have any insight???  Here are some snapshots for clarification. 

0 Kudos
Message 11 of 19
(2,819 Views)
Hi nelg87,

Sounds like this issue could be caused by a number of different things. But, first have some details about your set-up would be useful.
Do you have the Instruments on seperate buses (i.e. different GPIB cards)?
Is it when the first VI or the second VI tries to close the resource do you get?
How often does this problem occur, is it most of the time or just once  in a long while? 
Is it a particular circumstance or order of inputs that makes it crash?

I think we can get to the bottom of this.
-Marshall R
0 Kudos
Message 12 of 19
(2,787 Views)

Hi Marshall,

Here are some details... I'm using only one bus to control both power supplies.  I get the VISA close error only when I'm trying to exit one of the instruments and the other one its still running.  Doesn't matter which one I do first, if I have the other one open it will crash.  When I close the second one it closes with no error.  The VISA close error happens pretty much all the time... for some reason I have got it to close ok once or twice. 

By the way, I kept reading around and saw that the VISA close is really not needed so I ended up disabling the "close" on both instrument's vi and now I don't get the error.  So I'm leaving it up to the main app to close the session when it finishes... I know this is not good because I'm not freeing resources and right now when all instruments are up I'm using ~50% of CPU.  So any help to resolve this issue and be able to independently close the sessions will be greatly appreciated.

Thanks.

0 Kudos
Message 13 of 19
(2,782 Views)
That pretty much makes sense!  When you close a VISA reference, it closes it for all portions of the Labview code that may be using it. So instrument #1 closes it, but #2 still needs to write to it.  If you close it, you would need to do it once after both parts of the instrument code are done with it.
0 Kudos
Message 14 of 19
(2,768 Views)
Thanks for the quick reply, do you have a second GPIB card in that you could add to that system to see if the issue is caused by the fact that they are on the same bus?

Also, as a workaround you might put a wait on that close session until the VI for the other Power Supply is also ready to close. You could accomplish this by putting the Close Session VI in the main VI.
-Marshall R
0 Kudos
Message 15 of 19
(2,767 Views)
Very True Ravens Fan, but I believe nelg87 is using different VISA resources for each Power Supply so each close only closes the specific resource not both. But this would be a problem if both instruments are accessing the same resource. 

Nelg87, do you have different resource names for each power supply?
-Marshall R
0 Kudos
Message 16 of 19
(2,762 Views)


MXI Master wrote:
Very True Ravens Fan, but I believe nelg87 is using different VISA resources for each Power Supply so each close only closes the specific resource not both. But this would be a problem if both instruments are accessing the same resource. 

Nelg87, do you have different resource names for each power supply?


You might be correct.  I was thinking of a situation where someone may be talking to multiple devices on a single bus like on a serial RS-485.  So different parts of code would have VISA reads/writes to a Com port address (assuming the architecture is set up appropriately so the multiple parts don't step on each other.)
0 Kudos
Message 17 of 19
(2,756 Views)

Hi,

I do have different resources for my power supplies.  They are both in the same bus GPIB 0 but one is on address 5 and the other one on address 6. 

Something else I noticed when I open one of the lower level agilent AGE363X drivers, in particular the error handler vi... While the devices are up I see this vi changing from address 5 to address 6 continuosly.  Why is this happening? Shouldn't each instance of this vi reference it's own calling resource?  It's almost like there is only one instance of the lower vi's but I'm calling both of the power supplies vis separately with their own resource name.

0 Kudos
Message 18 of 19
(2,744 Views)
Hi nelg87,

I think we are running into a LabVIEW programing issue here. What is happening is that since you are calling the exact same VI with the same name and location on the hard disc around the same time, but with different inputs. I believe this is what is causing the erratic behavior due to virtual crossed wires.

I would suggest saving a copy of the driver in a different directory and renaming the VIs. Then replacing the VIs on the block diagram for one of the instruments with the new copy. I believe this will resolve this conflict.
-Marshall R
0 Kudos
Message 19 of 19
(2,734 Views)