04-02-2013 04:31 PM
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!
04-02-2013 05:35 PM
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.
04-02-2013 05:53 PM
^ 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.
04-02-2013 11:26 PM
I often build an Action Engine to handle all tasks related to the VISA session. Much easier to keep everything straight.
04-04-2013 10:41 AM
I understand cross, but I didn't write that program. I am only trying to make small improvement with big gain.
04-04-2013 11:25 AM - edited 04-04-2013 11:32 AM
@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.