5-4
Agilent 4155C/4156C VXIplug&play Driver User’s Guide, Edition 4
Programming Examples for C++ Users
Programming Basics
Table 5-1
Example Template Program Code for Visual C++
#include <stdio.h>
/* 1 */
#include <stdlib.h>
#include
<visa.h>
#include
"hp4156b.h"
void check_err (ViSession vi, ViStatus ret) {
/* 6 */
ViInt32
inst_err;
ViChar
err_msg[256];
if(VI_SUCCESS > ret) {
if ( hp4156b_INSTR_ERROR_DETECTED == ret ) {
hp4156b_error_query(vi, &inst_err, err_msg);
printf("Instrument Error: %ld\n %s\n", inst_err, err_msg);
}
else {
hp4156b_error_message(vi, ret, err_msg);
printf("Driver Error: %ld\n %s\n", ret, err_msg);
}
}
}
/* 20 */
void perform_meas (ViSession vi, ViStatus ret) {
/* 22 */
/* insert program code */
}
ViStatus main ( )
/* 26 */
{
ViStatus
ret;
/* 28 */
ViSession
vi;
ViChar
err_msg[256];
/* 30 */
Line
Description
1 to 4
Required to use the Agilent 4155/4156 VXI
plug&play
driver. The header files contain
various necessary information such as function declaration and macro definitions.
You may add the include statements to call another header files that may be needed by
the codes you added. Also, the include statements may be written in a header file that
will be called by the source file (e.g. #include <stdio.h> may be written in the stdafx.h
header file that will be called by the source file).
6 to 20
Checks if the passed “ret” value indicates normal status, and returns to the line that
called this subprogram. If the value indicates an instrument error status or a device error
status, the error message will be displayed.
22 to 24
Complete the perform_meas subprogram to perform measurement.
26
Beginning of the main program.
28 to 30
Declares variables used in the main program.
Содержание 4155C
Страница 3: ......
Страница 13: ...1 Installation...
Страница 18: ...1 6 Agilent 4155C 4156C VXIplug play Driver User s Guide Edition 4 Installation Installing VXIplug play Driver...
Страница 19: ...2 Driver Function Reference...
Страница 89: ...3 Programming Examples for Visual Basic Users...
Страница 147: ...4 Programming Examples for Visual Basic NET Users...
Страница 183: ...5 Programming Examples for C Users...
Страница 225: ...6 Programming Examples for VEE Users...
Страница 271: ...7 Sample Application Programs Using VEE...