VISA Resources and Attributes

From Agilent VISA.NET

VISA Resources and Attributes

This section introduces VISA resources and VISA attributes.

VISA Resources

In VISA, a resource is defined as any device (such as a voltmeter) with which VISA can provide communication. VISA defines six resource classes that a complete VISA system can implement. Each resource class includes:

  • Attributes to determine the state of a resource or session, or to set a resource or session to a specified state.
  • Events for communication with applications.
  • Operations (functions) that can be used for the resource class.

Note: Although the Servant Device-Side (SERVANT) resource is defined by the VISA specification, the SERVANT resource is not supported by Agilent VISA. The SERVANT resource is intended for advanced users who need to write code that causes a computer to function as an instrument rather than as a controller.

The table below describes each resource class supported by Agilent VISA.

Resource Class

Interface Types

Resource Class Description

Instrument Control (INSTR) Resource

Generic, GPIB, GPIB-VXI, PXI, Serial, TCPIP, USB, VXI

Device operations (reading, writing, triggering, etc.).

GPIB Bus Interface (INTFC) Resource

Generic, GPIB

Raw GPIB interface operations (reading, writing, triggering, etc.).

Memory Access (MEMACC) Resource

Generic, GPIB-VXI, PXI, VXI

Address space of a memory-mapped bus, such as the VXIbus.

VXI Mainframe Backplane (BACKPLANE) Resource

Generic, GPIB-VXI, VXI (GPIB-VXI BACKPLANE not supported)

VXI-defined operations and properties of each backplane in a VXIbus system.

TCPIP Socket (SOCKET) Resource

Generic, TCPIP

Operations and properties of a raw network socket connection using TCPIP.

VISA Attributes

Attributes are associated with resources or sessions. You can use attributes to determine the state of a resource or session, or to set a resource or session to a specified state.

For example, you can use the viGetAttribute function to read the state of an attribute for a specified session, event context, or find list. There are read only (RO) and read/write (RW) attributes. Use the viSetAttribute function to modify the state of a read/write attribute for a specified session, event context, or find list.

The pointer passed to viGetAttribute must point to the exact type required for that attribute (ViUInt16, ViInt32, etc.). For example, when reading an attribute state that returns a ViUInt16, declare a variable of that type and use it for the returned data. If ViString is returned, allocate an array and pass a pointer to that array for returned data.

Example: Reading a VISA Attribute

This example reads the state of the VI_ATTR_TERMCHAR_EN attribute and, if it is false, changes the state to true.

ViBoolean state, newstate;
newstate=VI_TRUE;
viGetAttribute(vi, VI_ATTR_TERMCHAR_EN, &state);
if (state err !=VI_TRUE) viSetAttribute(vi,
   VI_ATTR_TERMCHAR_EN, newstate);