2-21
Sample Programs
Listings of the Sample Programs
{ int header_length;
char header_str[8];
char term;
char xinc_str[32],xorg_str[32],xref_str[32];
char yinc_str[32],yref_str[32],yorg_str[32];
int bytes_read;
/* waveform data source channel 1 */
write_IO (":WAVeform:SOURce CHANnel1");
/* setup transfer format */
write_IO (":WAVeform:FORMat BYTE");
/* request values to allow interpretation of raw data */
write_IO (":WAVeform:XINCrement?");
bytes_read = read_IO (xinc_str,32L);
xinc = atof (xinc_str);
write_IO (":WAVeform:XORigin?");
bytes_read = read_IO (xorg_str,32L);
xorg = atof (xorg_str);
write_IO (":WAVeform:XREFerence?");
bytes_read = read_IO (xref_str,32L);
xref = atof (xref_str);
write_IO (":WAVeform:YINCrement?");
bytes_read = read_IO (yinc_str,32L);
yinc = atof (yinc_str);
write_IO (":WAVeform:YORigin?");
bytes_read = read_IO (yorg_str,32L);
yorg = atof (yorg_str);
write_IO (":WAVeform:YREFerence?");
bytes_read = read_IO (yref_str,32L);
yref = atof (yref_str);
write_IO (":WAVeform:DATA?"); /* request waveform data */
bytes_read = read_IO (data,1L); /* ignore leading # */
bytes_read = read_IO (header_str,1L); /* input byte counter */
header_length = atoi (header_str);
/* read number of points - value in bytes */
bytes_read = read_IO (header_str,(long)header_length);
Acquired_length = atoi (header_str); /* number of bytes */
bytes_read = read_IO (data,Acquired_length); /* input waveform data */
bytes_read = read_IO (&term,1L); /* input termination character */
} /* end transfer_data ( ) */
/*
* Function name: convert_data