2635A
Users Manual
4-62
/*
* HYDRALOG.C Hydra Program to scan VDC, VAC, OHMS, FREQ or TEMP
* - initializes RS-232 Communications between PC and Hydra
* - configures a number of Hydra channels for one type
* of measurement (e.g., VDC, VAC, temperature, etc.)
* - scan channels 3 times, and display and record measurement
* data on the screen and in file "testdata.prn"
*
* This program uses routines from the GreenLeaf Communications Library
* (asiopen(), asiputs(), and asigets_timed()) for sending and receiving
* information from the serial port connected to the Hydra. We recommend
* the use of a third-party serial communications library when developing
* C programs to communicate with Hydra instruments over PC serial ports.
*/
/*
* NOTE: Hydra must be set up for RS-232 communications, 1200 baud,
* no parity, 8 bit data
*/
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include "asiports.h" /* Greenleaf CommLib include file */
static FILE *testdata; /* File handle for output data file */
main(argc,argv)
int argc;
char *argv[];
{
int ret_code; /* code returned by various GreenLeaf
communications functions */
unsigned numChannels; /* Number of channels to be scanned */
unsigned index; /* counter */
char response[30]; /* Buffer for user response */
char sendbuff[129]; /* local buffer for transmitting to Hydra */
char recvbuff[129]; /* local buffer for receiving from Hydra */
/* Open and initialize COM2, the serial port the Hydra unit is attached
to, for 1200 baud, no parity, 8 it data, and ignore DTR and CTS */
ret_code = asiopen( COM2, (ASINOUT | BINARY | NORMALRX), 1000, 1000,
1200L, P_NONE, 1,8,FALSE,FALSE );
if ( ret_code < ASSUCCESS ) {
fprintf(stderr,"Failed to open the port, Greenleaf error: %d.\n",
ret_code );
exit(1);
}
/*send reset and uninstall */
asiputc (com2, '\x11');
asiputc (com2, '\x03');
checkResponse (); /* Get prompt */
op53_1f.eps

Figure 4-6. Sample Program (QuickC) (1of 5)