2-32
Sample Programs
Listings of the Sample Programs
natl_IO.c Sample Program
/* natl_IO.c */
#include <stdio.h> /* location of: printf ( ) */
#include <string.h> /* location of: strlen ( ) */
#include "hpibdecl.h"
/* This file contains IO and initialization routines for the NI488.2 commands. */
/*
* Function name: hpiberr
* Parameters: char* - string describing error
* Return value: none
* Description: This routine outputs error descriptions to an error file.
*/
void hpiberr( char *buffer )
{
printf ("Error string: %s\n",buffer );
} /* end hpiberr ( ) */
/*
* Function name: init_IO
* Parameters: none
* Return value: none
* Description: This routine initializes the NI environment. It sets up error
* handling, opens both an interface and device session, sets timeout values
* clears the interface by pulsing IFC, and clears the instrument by performing
* a Selected Device Clear.
*/
void init_IO ( )
{
bus = ibfind ( INTERFACE ); /* open and initialize GPIB board */
if ( ibsta & ERR )
hpiberr ("ibfind error");
ibconfig ( bus, IbcAUTOPOLL, 0); /* turn off autopolling */
ibsic ( bus ); /* clear interface - pulse IFC */
if ( ibsta & ERR )
{
hpiberr ( "ibsic error" );
}
/* open device session */
scope = ibdev ( board_index, prim_addr, second_addr, timeout,
eoi_mode, eos_mode );
if ( ibsta & ERR )
{
hpiberr ( "ibdev error" );
}