User`s guide

40 Agilent VISA User’s Guide
3 Programming with VISA
viOpenDefaultRM(&defaultRM);
viOpen(defaultRM, "GPIB0::23::INSTR", VI_NULL,
VI_NULL,&vi);
.
.
viClose(vi);
viClose(defaultRM);
Closing a Session
You must use the viClose function to close each session. You
can close the specific resource session, which will free all
data structures that had been allocated for the session. If
you close the default resource manager session, all sessions
opened using that resource manager session will be closed.
Since system resources are also used when searching for
resources (viFindRsrc), the viClose function needs to be
called to free up find lists. See the following section,
“Searching for Resources”, for more information on closing
find lists.
Searching for Resources
When you open the default resource manager, you are
opening a parent session that knows about all the other
resources in the system. Since the resource manager session
knows about all resources, it has the ability to search for
specific resources and open sessions to these resources. You
can, for example, search an interface for devices and open a
session with one of the devices found.
Use the viFindRsrc function to search an interface for
device resources. This function finds matches and returns
the number of matches found and a handle to the resources
found. If there are more matches, use the viFindNext
function with the handle returned from viFindRsrc to get
the next match:
viFindRsrc(sesn, expr, findList, retcnt,
instrDesc);
.