![HP E4401B Скачать руководство пользователя страница 70](http://html.mh-extra.com/html/hp/e4401b/e4401b_programmers-manual_161548070.webp)
3-6
Chapter 3
Programming Examples
C Programming Examples using VTL
Example Program
This example program queries an HP-IB device for an identification
string and prints the results. Note that you must change the address.
/*idn.c - program filename */
#include "visa.h"
#include <stdio.h>
void main ()
{
/*Open session to HP-IB device at address 18 */
ViOpenDefaultRM (&defaultRM);
ViOpen (defaultRM, “GPIB0::18::INSTR”, VI_NULL,
VI_NULL, &vi);
/*Initialize device */
viPrintf (vi, “*RST\n”);
/*Send an *IDN? string to the device */
printf (vi, “*IDN?\n”);
/*Read results */
viScanf (vi, "%t", &buf);
/*Print results */
printf (“Instrument identification string: %s\n”, buf);
/* Close the sessions */
viClose (vi);
viClose (defaultRM);
}
Including the VISA Declarations File
For C and C++ programs, you must include the
visa.h
header file at
the beginning of every file that contains VTL function calls:
#include “visa.h”
This header file contains the VISA function prototypes and the
definitions for all VISA constants and error codes. The
visa.h
header
file includes the
visatype.h
header file.
The
visatype.h
header file defines most of the VISA types. The VISA
types are used throughout VTL to specify data types used in the
functions. For example, the
viOpenDefaultRM
function requires a
pointer to a parameter of type
ViSession
. If you find
ViSession
in the
visatype.h
header file, you will find that
ViSession
is eventually
typed as an unsigned long.
Содержание E4401B
Страница 6: ...vi ...
Страница 14: ...xiv Contents ...
Страница 64: ...2 34 Chapter2 HP ESA Status Registers Using the Analyzer Status Registers ...
Страница 65: ...3 1 3 Programming Examples ...
Страница 118: ...3 54 Chapter3 Programming Examples Entering Amplitude Correction Data Close the session viClose viESA viClose defaultRM ...
Страница 151: ...4 1 4 Programming Command Cross References ...
Страница 286: ...5 132 Chapter5 Language Reference UNIT Subsystem ...
Страница 287: ...6 1 6 HP 8590 HP ESA Spectrum Analyzers Programming Conversion Guide ...
Страница 292: ...1 HP 8590 HP ESA Spectrum Analyzers Conversion Guide ...
Страница 368: ...7 1 7 Error Messages ...
Страница 393: ...7 26 Chapter7 Error Messages 201 to 799 Device Specific Errors ...