LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Does viClose need to be called with viOpenDefaultRM?

I know that you can call viClose after viOpenDefaultRM, but I'm wondering what happens if viClose is never called with the handle from viOpenDefaultRM. Will there be resources leftover? Also, does multiple calls to viOpenDefaultRM simply return the same handle, generate a new handle, or does it allocate and initialize the VISA library every time? If it allocates and initializes the VISA library every time, then viClose should probably be called. If it returns the same handle, there may be an issue when closing. For example:
- funcA calls viOpenDefaultRM and opens an instrument
- funcB calls viOpenDefaultRM and opens another instrument
- you call funcA, then funcB, then viClose on the the handle from funcA
According to the documentation, it seems as if both instruments will be closed since they were opened with the same RM handle. If this is the case, it may be better not to call viClose on the default RM. So should viClose be called with viOpenDefaultRM?
0 Kudos
Message 1 of 2
(4,560 Views)
viOpen is used to for individual instruments.....viOpenDefaultRM is used to establish a VISA session.  Generally, you would only have to call viOpenDefaultRM once in your application & the session handle it returns is then used as an argument to multiple viOpen commands for all your various intruments.  If for some reason you wanted to establish multiple VISA sessions, that would probably be due to some incompatibility or interoperability issues between instruments of different types that needed their own private VISA session.  ViClose is used to close either a VISA session or the individual device (instrument) sessions.  I think if you call it once & pass the VISA session handle (from viOpenDefaultRM), it will automatically close all individual device communication sessions also.  Not sure about that, tho.....it may not clean up as thouroughly as individual viClose commands.
0 Kudos
Message 2 of 2
(4,524 Views)