viSetAttribute

NI-VISA 15.0 Help

Edition Date: June 2015

Part Number: 370131S-01

»View Product Info

Purpose

Sets the state of an attribute.

C Syntax

ViStatus viSetAttribute(ViObject vi, ViAttr attribute, ViAttrState attrState)

Visual Basic Syntax

viSetAttribute&(ByVal vi&, ByVal attribute&, ByVal attrState&)

Resource Classes

All I/O session types

Parameters

Name Direction Description

vi

IN

Unique logical identifier to a session.

attribute

IN

Attribute for which the state is to be modified.

attrState

IN

The state of the attribute to be set for the specified object. The interpretation of the individual attribute value is defined by the object.

Return Values

Completion Codes Description

VI_SUCCESS

Attribute value set successfully.

VI_WARN_NSUP_ATTR_STATE

Although the specified attribute state is valid, it is not supported by this implementation.

Error Codes Description

VI_ERROR_INV_OBJECT

The given object reference is invalid.

VI_ERROR_NSUP_ATTR

The specified attribute is not defined by the referenced object.

VI_ERROR_NSUP_ATTR_STATE

The specified state of the attribute is not valid, or is not supported as defined by the object.

VI_ERROR_ATTR_READONLY

The specified attribute is Read Only.

VI_ERROR_RSRC_LOCKED

Specified operation could not be performed because the resource identified by vi has been locked for this kind of access.

Description

The viSetAttribute() operation is used to modify the state of an attribute for the specified object.

Both VI_WARN_NSUP_ATTR_STATE and VI_ERROR_NSUP_ATTR_STATE indicate that the specified attribute state is not supported. A resource normally returns the error code VI_ERROR_NSUP_ATTR_STATE when it cannot set a specified attribute state. The completion code VI_WARN_NSUP_ATTR_STATE is intended to alert the application that although the specified optional attribute state is not supported, the application should not fail. One example is attempting to set an attribute value that would increase performance speeds. This is different than attempting to set an attribute value that specifies required but nonexistent hardware (such as specifying a VXI ECL trigger line when no hardware support exists) or a value that would change assumptions a resource might make about the way data is stored or formatted (such as byte order).

Some attributes documented as being generally Read/Write may at times be Read Only. This is usually the case when an attribute configures how the VISA driver receives events of a given type, and the event type associated with that attribute is currently enabled. Under these circumstances, calling viSetAttribute on that attribute returns VI_ERROR_ATTR_READONLY.

The error code VI_ERROR_RSRC_LOCKED is returned only if the specified attribute is Read/Write and Global, and the resource is locked by another session.


Related Topics

Attributes

viGetAttribute

VISA Resource Template

WAS THIS ARTICLE HELPFUL?

Not Helpful