The Agilent 816x VXIplug&play Instrument Driver
230
Error Handling
Events and errors within a instrument control program can be detected by
polling (querying) the instrument. Polling is used in application
development environments (ADEs) that do not support asynchronous
activities where callbacks can be used.
Programs can set up and use polling as shown below.
Declare a variable to contain the function completion code.
1
ViStatus errStatus;
Every driver function returns the completion code
If the function executes with no I/O errors, driver errors, or instrument
errors,
is 0 (
ViStatus
If an error occurs,
ViStatus
Warnings are positive error codes, and indicate the operation
succeeded but special conditions exist.
Enable automatic instrument error checking following each function
2
call.
hp816x_errorQueryDetect
(instrumentHandle, VI_TRUE);
When enabled, the driver queries the instrument for an error condition
before returning from the function.
If an error occurred,
an error was detected (
Check for an error (or event) after each function.
3
errStatus = hp816x_cmd(instrumentHandle, "SENS1:POW:RANG");
check(instrumentHandle, errStatus);
After the function executes,
The completion code and instrument ID are passed to an error checking
routine. In the above statement, the routine is called 'check'.
Create a routine to respond to the error or event. This example queries
4
whether an error has occured, checks if the error is an instrument error
and then checks if the error is a driver error.
Agilent 8163A/B, 8164A/B & 8166A/B Mainframes, Fifth Edition
).
VI_SUCCESS
is a negative error code.
(Step 1) will contain a code indicating that
errStatus
hp816x_INSTR_ERROR_DETECTED
contains the completion code.
errStatus
Error Handling
.
ViStatus
).