Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA open/read no close

I am working on a program with a lot of VISA read and write, but they are all using separate VISA session and are not closed.  Would that be a problem?  If it is, is there a quick way to fix them all?  I really don't want to add a close reference behind each one of them.  Thanks!

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 1 of 6
(4,199 Views)

You should really only be setting up the VISA session once at the start of the program and closing at the end.  You can then read and write as much as you want in the middle.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 6
(4,188 Views)

^ Yup. 

 

Once you configure and open the port with the VISA-Open tool, just pass the task around and read/write using that. 

Close the port at the end to free it up for other programs to use.

 

If you put a VISA-Open in a for-loop, you're just creating a huge memory leak and opening yourself up to all kinds of communication problems. 

 

tl;dr: Open the port at the beginning of the program, close it at the end.

Message 3 of 6
(4,184 Views)

I often build an Action Engine to handle all tasks related to the VISA session.  Much easier to keep everything straight.

 

Message 4 of 6
(4,175 Views)

I understand cross, but I didn't write that program.  I am only trying to make small improvement with big gain.  

------------------------------------------------------------------

Kudos and Accepted as Solution are welcome!
0 Kudos
Message 5 of 6
(4,147 Views)

@jyang72211 wrote:

I understand cross, but I didn't write that program.  I am only trying to make small improvement with big gain.  


In that case just use the ini file setting to automatically close those  VISA sessions.

Tools>>Options>>Evironment.  its the top radio button

 

Wayne's advice should be heeded for future development.


"Should be" isn't "Is" -Jay
Message 6 of 6
(4,140 Views)