EasyManua.ls Logo

Agilent Technologies E4438C - Queries Using VISA and C

Agilent Technologies E4438C
208 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Programming Examples
RS-232 Programming Examples
Chapter 298
Queries 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.
The following program example is available on the ESG 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)
{
ViStatus status; // Declares a type ViStatus variable
ViSession defaultRM, instr;// Declares type ViSession variables
ViUInt32 retCount; // Return count for string I/O
ViChar buffer[MAX_COUNT];// Buffer for string I/O
status = viOpenDefaultRM(&defaultRM);// Initializes the system
// Open communication with Serial Port 2
status = viOpen(defaultRM, "ASRL2::INSTR", VI_NULL, VI_NULL, &instr);
if(status){ // If problems, then prompt user
printf("Could not open ViSession!\n");
printf("Check instruments and connections\n");

Table of Contents

Other manuals for Agilent Technologies E4438C

Related product manuals