niModInst_GetInstalledDeviceAttributeViString

ModInst

niModInst_GetInstalledDeviceAttributeViString

Specific Function

C Function Prototype

ViStatus niModInst_GetInstalledDeviceAttributeViString (ViSession handle, ViInt32 index, ViInt32 attributeID, ViInt32 attributeValueBufferSize, ViChar attributeValue[]);

Description

Returns a string attribute specified by the attributeID parameter for a device specified by the handle and index parameters. The handle parameter is expected to be a valid handle returned by niModInst_OpenInstalledDevicesSession. Therefore, it acts as a handle to a list of installed devices. The index parameter specifies for which device in the list you want the attribute.

To find out the length of the device name string before you allocate a buffer for it, simply call this function and pass 0 as the attributeValueBufferSize parameter or NULL as the attributeValue parameter. When you do this, the function returns the size of the buffer required to hold the attribute value string as its return value. You can then allocate an appropriately sized character buffer and call this function again.

Parameters

Name Type Description
handleViSessionThe NI-ModInst session handle created by niModInst_OpenInstalledDevicesSession.
indexViInt32A zero-based index that specifies the device for which you want the attribute. This index parameter should be between 0 and (deviceCount – 1), inclusive, where deviceCount is the number of installed devices returned by niModInst_OpenInstalledDevicesSession.
attributeIDViInt32The ID of the string attribute you want to query.

Valid Values

NIMODINST_ATTR_DEVICE_NAME—the name of the device, which can be used to open an instrument driver session for that device

NIMODINST_ATTR_DEVICE_MODEL—the model of the device (for example, NI PXI-5122)

NIMODINST_ATTR_SERIAL_NUMBER—the serial number of the device

attributeValueBufferSizeViInt32The size of the buffer allocated and passed in as the attributeValue parameter. The buffer should be large enough to hold the attribute value string (including a NULL terminating character). Refer to the Description section for information on how to determine the exact buffer size required.
attributeValueViChar[]The character buffer into which the attribute value string is copied.

Return Value

Reports the return status of the function call. To obtain a text description of the status code, call niModInst_GetExtendedErrorInfo.

Note   The return value for this function has a second purpose. If the attributeValueBufferSize is less than the size required to hold the attribute value string, or if the attributeValue parameter is NULL, the return value is the size of the buffer required to hold the attribute value string, including a NULL terminating character.