Anritsu ML2430A Uživatelský manuál Strana 220

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 271
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 219
Binary Output
Message Decoding
The following program example may be used to decode the three types of binary
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
GPIB OPERATION PROGRAMMING EXAMPLES
Zobrazit stránku 219
1 2 ... 215 216 217 218 219 220 221 222 223 224 225 ... 270 271

Komentáře k této Příručce

Žádné komentáře