Agilent Technologies E8663B Portable Generator User Manual


 
Agilent N518xA, E8663B, E44x8C, and E82x7D Signal Generators Programming Guide 135
Programming Examples
RS-232 Programming Interface Examples (ESG/PSG/E8663B Only)
Queries for RS-232 Using VISA and C
This example uses VISA library functions to communicate with the signal generator. The program
verifies that the RS-232 connections and interface are functional. Launch Microsoft Visual C++, add
the required files, and enter the following code into your .cpp source file. rs232ex2.cpp performs
the following functions:
•error checking
reads the signal generator response
flushes the read buffer
queries the signal generator for power
reads the signal generator power
The following program example is available on the signal generator Documentation CD-ROM as
rs232ex2.cpp.
//************************************************************************************
//
// PROGRAM NAME: rs232ex2.cpp
//
// PROGRAM DESCRIPTION: This code example uses the RS-232 serial interface to control
// the signal generator.
//
// Connect the computer to the signal generator using the RS-232 serial cable
// and enter the following code into the project .cpp source file.
// The program queries the signal generator ID string and sets and queries the power
// level. Query results are printed to the screen. The default attributes e.g. 9600 baud,
// parity, 8 data bits,1 stop bit are used. These attributes can be changed using VISA
// functions.
//
// IMPORTANT: Set the signal generator BAUD rate to 9600 for this test
//************************************************************************************
#include <visa.h>
#include <stdio.h>
#include "StdAfx.h"
#include <stdlib.h>
#include <conio.h>
#define MAX_COUNT 200
int main (void)
{
ViStatusstatus; // Declares a type ViStatus variable