viSetAttribute
Syntax
viSetAttribute(ViSession/ViEvent/ViFindList vi, ViAttr attribute, ViAttrState attrState);
Description
This function sets the state of an attribute for the specified session. The viSetAttribute operation is used to modify the state of an attribute for the specified session, event, or find list.
If a resource cannot set an optional attribute state and the specified attribute state is valid and the attribute description does not specify otherwise, viSetAttribute returns error code VI_ERROR_NSUP_ATTR_STATE.
Both VI_WARN_NSUP_ATTR_STATE and VI_ERROR_NSUP_ATTR_STATE indicate that the specified attribute state is not supported. Unless a specific rule states otherwise, 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). See specific attribute descriptions for text that allows the completion code VI_WARN_NSUP_ATTR_STATE.
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.
Parameters
Name |
Dir |
Type |
Description |
---|---|---|---|
vi |
IN |
ViSession |
Unique logical identifier to a session, event, or find list. |
attribute |
IN |
ViAttr |
Resource attribute for which the state is modified. |
attrState |
IN |
ViAttrState |
The state of the attribute to be set for the specified resource. The interpretation of the individual attribute value is defined by the resource. |
Return Values
Type ViStatus |
This is the function return status. It returns either a completion code or an error code as follows. |
Completion Code |
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 resource implementation. (The application will still work, but this may have a performance impact.) |
Error Code |
Description |
VI_ERROR_ATTR_READONLY |
The specified attribute is read-only. |
VI_ERROR_INV_SESSION |
The given session or object reference is invalid (both are the same value). |
VI_ERROR_NSUP_ATTR |
The specified attribute is not defined by the referenced resource. |
VI_ERROR_NSUP_ATTR_STATE |
The specified state of the attribute is not valid, or is not supported as defined by the resource. (The application probably will not work if this error is returned.) |
VI_ERROR_RSRC_LOCKED |
Specified operation could not be performed because the resource identified by vi has been locked for this kind of access. |
See Also
viGetAttribute. See VISA Resource Classes for a list of attributes and attribute values.