EasyManua.ls Logo

Anritsu ML2400A Series - Page 223

Anritsu ML2400A Series
275 pages
Print Icon
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...
Bi nary Out put
Mes sage De coding
The fol low ing pro gram ex am ple may be used to de code the three types of bi -
nary out put mes sages. The com mands that ref er ence this code ex am ple are
OGBD, MXGDB and MNGDB for the GRAPH_BINARY_DATA de cod ing;
OFFTBR for the OFFSET_TABLE_BINARY_DATA de cod ing; and CFURD for
the CAL_FACTOR_BINARY_DATA de cod ing.
/*************************************************************************/
/* Decode binary outputs example */
/* This function expects the binary response from the command to be held in a global */
/* character array buffer. The passed parameter ‘decode type’ will be one of the global */
/* definitions */
/* GRAPH_BINARY_DATA */
/* OFFSET_TABLE_BINARY_DATA, CAL_FACTOR_BINARY_DATA */
/*************************************************************************/
void buffer_decode(int decode_type)
{
int count;
long *bin_value;
char *cptr;
char ch_val[6];
int length;
if (decode_type == GRAPH_BINARY_DATA)
{
/* FOR OGBD, MXGDB and MNGDB */
/********************* Decode header ************************/
/* Find # character. */
cptr = strtok(&buffer[0],"#");
cptr = strtok(NULL,"#");
/* Get the number of characters for binary length */
ch_val[0] = *cptr++;
ch_val[1] = NULL;
count = atoi(&ch_val[0]);
/* Get length of binary data */
for (loop = 0; loop < count; loop++)
{
ch_val[loop] = *cptr++;
}
ch_val[count] = NULL;
length = atoi(&ch_val[0]);
/* If reading in a binary graph the data will be in */
/* 1024LONG format. In this format each of the graph */
/* values are held as the dB value multiplied by 1024 */
/* and held in LONG form. */
/* */
/* Each long is 4 byte in length. To read and transpose
the values into real dB values each set of 4 bytes
are read into a long variable and then cast into a
float type and then divided by 1024.
*/
count = 0;
loop = 0;
bin_value = (long *)cptr; /* Set the long pointer */
6-136 ML2400A OM
PROGRAMMING EXAMPLES GPIB OPERATION

Table of Contents

Related product manuals