LabWindows/CVI

Status Checking

Most instruments support the ability to query the status of the instrument. The instrument returns an indication of whether it has encountered any errors. IVI instrument drivers have the ability to check the instrument status after every function that interacts with the instrument. IVI provides users with the ability to enable or disable status checking. Status checking is most useful during debugging. After users validate their programs, they can disable status checking to maximize performance. By default, status checking is enabled. The user disables status checking by setting the IVI_ATTR_QUERY_INSTR_STATUS attribute to VI_FALSE, by setting the QueryInstrStatus tag in the optionsString parameter of Prefix_InitWithOptions to VI_FALSE , or by specifying the QueryInstrStatus entry to be false in MAX.

An instrument driver defines a check status callback to encapsulate the code that queries the instrument status and interprets the response.

The IVI Engine invokes the check status callback only when a user calls one of the Prefix_SetAttribute or Prefix_GetAttribute functions that an instrument driver exports. The instrument driver marks these calls by passing the IVI_VAL_DIRECT_USER_CALL flag to the Ivi_SetAttribute or Ivi_GetAttribute function. In this case, the IVI Engine invokes the check status callback after it invokes the read or write callback, but only if the IVI_ATTR_QUERY_INSTR_STATUS attribute is VI_TRUE.

When other instrument driver functions call the Ivi_SetAttribute or Ivi_GetAttribute functions, the IVI Engine does not invoke the check status callback. Because high-level functions often make multiple calls to the Ivi_SetAttribute and Ivi_GetAttribute functions, invoking the check status callback each time would be inefficient. Consequently, the high-level functions must invoke the check status callback before returning. They must do so only if the IVI_ATTR_QUERY_INSTR_STATUS attribute is VI_TRUE and only if instrument I/O has actually occurred. Instrument I/O occurs when a high-level function performs direct instrument I/O or when calls to the Ivi_SetAttribute functions invoke write callbacks because the cache values are invalid or not equal to the requested values.

The IVI Engine contains the Ivi_QueryInstrStatus function that instrument drivers can call to determine whether the IVI_ATTR_QUERY_INSTR_STATUS attribute is VI_TRUE. The IVI Engine also contains the Ivi_NeedToCheckStatus function that instrument drivers can call to determine whether any instrument interaction has occurred since the last time the driver or the IVI Engine invoked the check status callback. To help drivers maintain this information, the IVI Engine contains the Ivi_SetNeedToCheckStatus function. After an instrument driver performs status checking, it must call Ivi_SetNeedToCheckStatus with VI_FALSE. Before performing direct instrument I/O, the instrument driver must call Ivi_SetNeedToCheckStatus with VI_TRUE. If you use the Tools»IVI Development»Create IVI Specific Driver command to generate a driver based on a class definition, the initial instrument driver source code contains a Prefix_CheckStatus function that handles these requirements. The skeleton code for the high-level functions calls Prefix_CheckStatus.