Technical data
146 Chapter 9 
Programming Examples
Programming in C Using the VISA
Programming Examples
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 device address specified in the rsrcName parameter to 
open a device session. The vi parameter in viOpen returns a session 
identifier that can be used with other VISA functions.
Your program may have several sessions open at the same time by 
creating multiple session identifiers by calling the viOpen function 
multiple times.
The following summarizes the parameters in the previous function 
calls:
sesn  This is a session returned from the viOpenDefaultRM 
function that identifies the resource manager session.
rsrcName  This is a unique symbolic name of the device (device 
address).
accessMode  This parameter is not used for VISA. Use VI_NULL.
timeout  This parameter is not used for VISA. Use VI_NULL.
vi  This is a pointer to the session identifier for this 
particular device session. This pointer will be used to 
identify this device session when using other VISA 
functions.
The following is an example of opening sessions with a GPIB 
multimeter and a spectrum analyzer on LAN:
ViSession defaultRM, dmm, sa;
.
.
viOpenDefaultRM(&defaultRM);
viOpen (defaultRM, "GPIB0::22::INSTR", VI_NULL,
VI_NULL, &dmm);
viOpen (defaultRM, "TCPIP0::192.168.0.2::inst0::INSTR", 
VI_NULL,
VI_NULL, &sa);
.
.
viClose (sa);
viClose (dmm);
viClose(defaultRM);
The above function first opens a session with the default resource 
manager. The session returned from the resource manager and a device 
address is then used to open a session with the GPIB device at address 
22. That session will now be identified as dmm when using other VISA 
functions. The session returned from the resource manager is then used 
to open a session with the LAN device at IP Address 192.168.0.2. That 
session will now be identified as sa when using other VISA functions. 
See the following section for information on addressing particular 










