User`s guide

Programming with VISA 3
Agilent VISA User’s Guide 31
Opening a Session
A session is a channel of communication. Sessions must first be opened
on the default resource manager, and then for each resource you will be
using.
A resource manager session is used to initialize the VISA system. It
is a parent session that knows about all the opened sessions. A
resource manager session must be opened before any other session
can be opened.
A resource session is used to communicate with a resource on an
interface. A session must be opened for each resource you will be
using. When you use a session you can communicate without
worrying about the type of interface to which it is connected. This
insulation makes applications more robust and portable across
interfaces.
Resource Manager Sessions
There are two parts to opening a communications session with a specific
resource. First, you must open a session to the default resource manager
with the viOpenDefaultRM function. The first call to this function
initializes the default resource manager and returns a session to that
resource manager session. You only need to open the default manager
session once. However, subsequent calls to viOpenDefaultRM return a
unique session to the same default resource manager resource.
Resource Sessions
Next, open a session with a specific resource using the viOpen function.
This function uses the session returned from viOpenDefaultRM and
returns its own session to identify the resource session. The following
shows the function syntax.
viOpenDefaultRM(sesn);
viOpen(sesn, rsrcName, accessMode, timeout,
vi);
The session returned from viOpenDefaultRM must be used in the sesn
parameter of the viOpen function. The viOpen function then uses that
session and the resource address specified in the rsrcName parameter to
open a resource session. The vi parameter in viOpen returns a session
identifier that can be used with other VISA functions.