User`s guide

36 Agilent VISA User’s Guide
3 Programming with VISA
Sample: Opening a Resource Session
This code sample shows one way of opening resource
sessions with a GPIB multimeter and a GPIB- VXI scanner.
The sample first opens a session with the default resource
manager. The sample then uses the session returned from
the resource manager, and a VISA address, to open a session
with the GPIB device at address 22. You can now identify
that session as dmm when you call other VISA functions.
The sample again uses the session returned from the
resource manager, with another VISA address, to open a
session with the GPIB- VXI device at primary address 9 and
VXI logical address (secondary address) 24. You will now
identify this session as scanner when calling other VISA
functions. See the following section, “Addressing a Session”,
for information on addressing particular devices.
ViSession defaultRM, dmm, scanner;
.
viOpenDefaultRM(&defaultRM);
viOpen(defaultRM, "GPIB0::22::INSTR",VI_NULL,
VI_NULL,&dmm);
viOpen(defaultRM, "GPIB-VXI0::24::INSTR",
VI_NULL, VI_NULL,&scanner);
.
viClose(scanner);
viClose(dmm);
viClose(defaultRM);
Addressing a Session
As shown in the previous section, the rsrcName parameter
in the viOpen function is used to identify a specific
resource. This parameter consists of the VISA interface ID
and the resource address. The interface ID is determined
when you run the Agilent Connection Expert utility. The
interface ID is usually the VISA interface type followed by a
number.