Anritsu operation manual ML2430A OM 133

Models: ML2430A

1 271
Download 271 pages 6.82 Kb
Page 220
Image 220

GPIB OPERATION

PROGRAMMING EXAMPLES

Binary Output The following program example may be used to decode the three types of binary

Message Decoding output messages. The commands that reference this code example are OGBD, MXGDB and MNGDB for the GRAPH_BINARY_DATA decoding; OFFTBR for the OFFSET_TABLE_BINARY_DATA decoding; and CFURD for the CAL_FACTOR_BINARY_DATA decoding.

/*************************************************************************/

/*

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 */

ML2430A OM

6-133

 

 

Page 220
Image 220
Anritsu operation manual ML2430A OM 133