The Agilent 816x VXIplug&play Instrument Driver Error Handling
230 Agilent 8163A/B, 8164A/B & 8166A/B Mainframes, Fifth Edition
Error Handling
Events and errors within a instrument co ntrol program can be detected by
polling (querying) the inst rument. 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 pollin g as shown below.
1Declare a variable to contain the function completion code.
ViStatus errStatus;
Every driver function returns the completion code ViStatus.
If the function executes with no I/O errors, driver er rors, or instrument
errors, ViStatus is 0 (VI_SUCCESS).
If an error occurs, ViStatus is a negative error code.
Warnings are positive error codes, and ind icate the operation
succeeded but special conditions exist.
2Enable automatic instrument error checking following each function
call.
hp816x_errorQuer yDetect
(instrumentHandle, VI_TRUE);
When enabled, the driver queries the instrument for an e rror condition
before returning from the function.
If an error occurred, errStatus (Step 1) will contain a code indicating that
an error was detected (hp816x_INSTR_ERROR_DETECTED).
3Check for an error (or event) after each function.
errStatus = hp816x_cmd(instrum entHandle, "SENS1:POW:RANG ");
check(instrumentHandle, errStatus);
After the function executes, errStatus contains the completion code.
The completion code and instrument ID are passed to an error checking
routine. In the above statement, the routine is called 'check'.
4Create a routine to respond to the error or event. This e xample queries
whether an error has occured, checks if the error is an instrument error
and then checks if the error is a driver error.