niDCPower_GetAttributeViString

NI-DCPower Function Reference

niDCPower_GetAttributeViString

ViStatus niDCPower_GetAttributeViString(ViSession vi, ViConstString channelName, ViAttr attribute, ViInt32 bufferSize, ViChar value[])

Purpose

Queries the value of a ViString attribute.

You can use this function to get the values of device-specific attributes and inherent IVI attributes. If the attribute represents an device state, this function performs device I/O in the following cases:

  • State caching is disabled for the entire session or for the particular attribute.
  • State caching is enabled and the currently cached value is invalid.

Parameters

Input
Name Type Description
vi ViSession Identifies a particular instrument session. vi is obtained from the niDCPower_init or niDCPower_InitWithOptions function.
channelName ViConstString If the attribute is channel-based, this attribute specifies the name of the channel on which to set the value of the attribute. If the attribute is not channel-based, then pass VI_NULL or an empty string. Valid channel names are 0, 1, and 2.
attribute ViAttr Specifies the ID of an attribute. From the function panel window, you can use this control as follows.
  • In the function panel window, click on the control or press Enter or the spacebar to display a dialog box containing hierarchical list of the available attributes. Help text is shown for each attribute. Select an attribute by double-clicking on it or by selecting it and then pressing Enter.
  • A ring control at the top of the dialog box allows you to see all IVI attributes or only the attributes of type ViString. If you choose to see all IVI attributes, the data types appear to the right of the attribute names in the list box. Attributes with data types other than ViString are dim. If you select an attribute data type that is dim, LabWindows/CVI transfers you to the function panel for the corresponding function that is consistent with the data type.
  • If you want to enter a variable name, press Ctrl+T to change this ring control to a manual input box. If the attribute in this ring control has named constants as valid values, you can view the constants by moving to the value control and pressing Enter.
bufferSize ViInt32 Passes the number of bytes in the buffer and specifies the number of bytes in the ViChar array you specify for value. If the current value of value, including the terminating NUL byte, is larger than the size you indicate in this attribute, the function copies (buffer size - 1) bytes into the buffer, places an ASCII NUL byte at the end of the buffer, and returns the buffer size you must pass to get the entire value. For example, if the value is 123456 and the buffer size is 4, the function places 123 into the buffer and returns 7.

To obtain the required buffer size, you can pass 0 for this attribute and VI_NULL for value. If you want the function to fill in the buffer regardless of the number of bytes in the value, pass a negative number for this attribute.
Output
Name Type Description
value ViChar[] The buffer in which the function returns the current value of the attribute. The buffer must be of type ViChar and have at least as many bytes as indicated in bufferSize.

If the current value of the attribute, including the terminating NUL byte, contains more bytes that you indicate in this attribute, the function copies (buffer size -1) bytes into the buffer, places an ASCII NUL byte at the end of the buffer, and returns the buffer size you must pass to get the entire value. For example, if the value is 123456 and the buffer size is 4, the function places 123 into the buffer and returns 7.

If you specify 0 for bufferSize, you can pass VI_NULL for this attribute.

If the attribute currently showing in the attribute ring control has constants as valid values, you can view a list of the constants by pressing Enter on this control. Select a value by double-clicking on it or by selecting it and then pressing Enter.

Return Value

Name Type Description
StatusViStatus

Reports the status of this operation. To obtain a text description of the status code, call niDCPower_error_message. To obtain additional information concerning the error condition, call niDCPower_GetError.