42 Chapter 2
Programming Examples
GPIB Programming Examples
cout<<endl;
return 0;
}
Queries Using VISA and C
This example uses VISA library functions to query different instrument states and conditions. Launch
Microsoft Visual C++ 6.0, add the required files, and enter the following code into your .cpp source file.
The following program example is available on the PSG Documentation CD-ROM as visaex3.cpp.
//****************************************************************************************
// PROGRAM FILE NAME:visaex3.cpp
//
// PROGRAM DESCRIPTION:This example demonstrates the use of query commands. The signal
// generator can be queried for conditions and instrument states. These commands are of
// the type "*IDN?"; the question mark indicates a query.
//
//****************************************************************************************
#include <visa.h>
#include "StdAfx.h"
#include <iostream>
#include <conio.h>
#include <stdlib.h>
using namespace std;
void main ()
{
ViSession defaultRM, vi; // Declares variables of type ViSession
// for instrument communication
ViStatus viStatus = 0; // Declares a variable of type ViStatus
// for GPIB verifications
char rdBuffer [256]; // Declares variable to hold string data