Agilent 4155C/4156C VXIplug&play Driver User’s Guide, Edition 4 5-5
Programming Examples for C++ Users
Programming Basics
/* Starting the session */
ret = hp4156b_init("GPIB::17::INSTR", VI_TRUE, VI_TRUE, &vi); /* 33 */
if ( ( ret < VI_SUCCESS ) || ( vi == VI_NULL ) ) {
printf("Initialization failure.\n Status code: %d.\n", ret);
if ( vi != VI_NULL ) {
hp4156b_error_message(vi, ret, err_msg);
printf("Error: %ld\n %s\n", ret, err_msg);
}
exit (ret);
} /* 41 */
ret = hp4156b_reset(vi); /* resets 4155/4156 43 */
ret = hp4156b_timeOut(vi, 60000); /* sets 60 second timeout */
ret = hp4156b_errorQueryDetect(vi, VI_TRUE); /* turns on error detection */
perform_meas(vi, ret); /* calls perform_meas subprogram 47 */
/* ret = hp4156b_cmd(vi, "aa"); sends an invalid command */
/* check_err(vi, ret); checks check_err subprogram operation */
/* Closing the session
ret = hp4156b_close(vi); 52 */
check_err(vi, ret);
return VI_SUCCESS; /* 55 */
}
Line Description
33 Establishes the software connection with the Agilent 4155/4156. The above example is
for the Agilent 4155/4156 on the GPIB address 17. Confirm the GPIB address of your
4155/4156, and set the address correctly instead of “17”.
34 to 41 Checks the status returned by the hp4156b_init function. Displays the error message
and stops the program execution if an error status is returned.
43 to 45 Resets the Agilent 4155/4156, sets the driver I/O time out to 60 seconds, and enables
the automatic instrument error checking.
47 Calls the perform_meas subprogram (line 22).
48 to 49 Should be deleted or commented out before executing the program. The lines are just
used to check the operation of the check_err subprogram.
52 Disables the software connection with the Agilent 4155/4156.
53 Calls the check_err subprogram to check if an error status is returned for the line 52.
55 to 56 End of the main program.