Chapter 9 Checking for Errors in LabWindows/CVI
©
National Instruments Corporation 9-5 LabWindows/CVI Programmer Reference Manual
iberr. After each GPIB call, your program should check whether the ERR bit is set to
determine if an error has occurred, as shown in the following code segment.
if (ibwrt(bd[instrID], buf, cnt) & ERR)
PREFIX_err = 230;
Refer to your NI-488.2 Function Reference and user manuals for detailed information on
GPIB global variables and listings of status and error co des. LabWindows/CVI function panel
help also has listings of status and error codes.
RS-232 Library
The RS-232 library returns status information through a global variable called rs232err. If
this variable is negative after the function returns, an error occurred. Notice that many of the
functions return a value in addition to setting the global variable. Usually, this value contains
information on the result of the function that can also be used to detect a problem. Each
function should be checked individually. Refer to the RS-232 section in the LabWindows/CVI
Standard Libraries Reference Manual or the function panel h elp for a listing of the error codes
and information on the individual functions. Yo u can use GetRS232ErrorString to get the
error message associated with each RS-232 Library errorcode.
Note If your program uses multiple threads, use the ReturnRS232Err function in
place of the rs232err global variable.
VISA Library
The VISA Library functions return a negative value when they detect an error. They return a
positive value as a warning when they can complete their task but not in the way you might
expect. This library uses a common set of error and warning codes, but the warning code
values are entirely separate from the error code values. The error codes always contain
0xBFFF in the upper two bytes. The warning codes always contain 0x3FFF in the upper two
bytes. Refer to the NI-VISA Programmer Reference Manual or the function panel help for a
listing of the error and warning codes and information on the individual functions. You can
use viStatusDesc to obtain the error message associated with each VISA Library error
code.
IVI Library
The IVI Library functions return a negative value when they detect an error. This library uses
a common set of error codes. Refer to the LabWindows/CVI Instrument Driver Developers
Guide or the function panel help for a listing of the error codes and information on the
individual functions. IVI Library functions sometimes also provide a secondary error code or
an elaboration string to give you additional information about an error condition. You can use
Ivi_GetErrorInfo to obtain the primary error code, secondary error code, and the
elaboration string. You can use Ivi_GetErrorMessage to obtain the error message
associated with each IVI Library error code.

00ProRef.book : 06chap09.fm Page 5 Monday, March 9, 1998 3:23 PM