Admin Production ni-theme
Current Publication

Ivi_ValidateAttribute

IVI Compliance Package

Ivi_ValidateAttribute

Usage

ViStatus Ivi_ValidateAttribute (ViSession vi, ViAttr attributeID, IviValueType expectedType);

Purpose

This function checks if an attribute with the specified ID and type has been added to the session.

If an attribute with the given ID and type exists, the function returns VI_SUCCESS.

If an attribute with the given ID does not exist, the function returns the IVI_ERROR_INVALID_ATTRIBUTE error. For class driver sessions, if the attribute ID corresponds to an attribute that is created only by the class driver, the function returns the IVI_ERROR_NOT_CREATED_BY_CLASS error.

If an attribute with the given ID and type exists, but is marked with the IVI_VAL_NOT_SUPPORTED flag, the function returns the IVI_ERROR_ATTRIBUTE_NOT_SUPPORTED error.

If an attribute with the given ID exists but is of a different or unknown type, the function returns the IVI_ERROR_TYPES_DO_NOT_MATCH error.

Parameters

Input
Name Type Description
vi ViSession The ViSession handle that you obtain from Ivi_SpecificDriverNew. The handle identifies a particular IVI session.
attributeID ViAttr Pass the ID of an attribute for this parameter.

The include file for a specific instrument driver defines constant names for all of the user-accessible attributes that apply to the driver. This includes attributes that the IVI engine defines, attributes that the instrument class defines, and attributes that are specific to the particular instrument. Each defined constant name begins with PREFIX_ATTR_, where PREFIX is the specific instrument prefix.

For each IVI engine attribute, the specific driver include file uses the same constant name that appears in ivi.h, except that the specific instrument prefix replaces the IVI prefix. For example, ivi.h defines IVI_ATTR_CACHE, and the Fluke 45 include file, fl45.h, defines the following constant name:

#define FL45_ATTR_CACHE  IVI_ATTR_CACHE

For each instrument class attribute, the specific driver include file uses the same constant name that appears in the instrument class include file, except that the specific instrument prefix replaces the class prefix. For example, the DMM class include file, ividmm.h, defines IVIDMM_ATTR_RANGE, and fl45.h defines the following constant name:

#define FL45_ATTR_RANGE  IVIDMM_ATTR_RANGE

For each specific instrument attribute, the specific driver include file defines a constant name and assigns a value that is an offset from IVI_SPECIFIC_PUBLIC_ATTR_BASE. For example, fl45.h defines the following constant name:

#define FL45_ATTR_HOLD_THRESHOLD \ (IVI_SPECIFIC_PUBLIC_ATTR_BASE + 3L)

For each attribute that is private to an instrument driver, the instrument driver source file defines a constant name and assigns a value that is an offset from IVI_SPECIFIC_PRIVATE_ATTR_BASE. For example, hp34401a.c defines the following constant name:

#define HP34401A_ATTR_TRIGGER_TYPE \ (IVI_SPECIFIC_PRIVATE_ATTR_BASE + 1L)

expectedType IviValueType Specifies the expected type of the attribute that you want to validate.

Defined Values:

  • IVI_VAL_INT32 (1L)—ViInt32
  • IVI_VAL_INT64 (2L)—ViInt64
  • IVI_VAL_REAL64 (4L)—ViReal64
  • IVI_VAL_STRING (5L)—ViString
  • IVI_VAL_ADDR (10L)—ViAddr
  • IVI_VAL_SESSION (11L)—ViSession
  • IVI_VAL_BOOLEAN (13L)—ViBoolean

Return Value

Contains the status code that the function call returns. IVI engine functions can return error and warning values from several sets of status codes. Some status codes are unique to the IVI engine. Other status codes are the same codes that VISA Library functions return. Still others are error or warning values that functions in specific instrument drivers return. Each set of status codes has its own numeric range.

Regardless of the source of the status code, 0 always indicates success, a positive value indicates a warning, and a negative value indicates an error.

Related Topic

IVI Status Codes