EasyManua.ls Logo

Fluke 2635A - Page 242

Fluke 2635A
268 pages
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...
2635A
Users Manual
C-8
/* Globals convert() uses for destination */
int timestamp[6]; /* Scan timestamp */
int misc[3]; /* Temperature units, measurement rate, digital I/O */
float values[22]; /* Measurement values */
extern int isnan(); /* Floating point value is NaN (not a number) */
extern int isinf(); /* Floating point value is Inf (infinity) */
/*
-* main(): LOG_BIN? query response example program
**
** Converts a hard-coded LOG_BIN? response string into usable data.
*/
main()
{
extern int decode(); /* ASCII to binary decoding */
extern void convert(); /* Convert Hydra binary to usable types */
/* Canned response for three channels: channel 1 is OTC, channel 5 is */
/* OL and channel 10 is 1.0; remaining encoded data described below */
/* (note that you can not determine the channel number, measurement */
/* units, or measurement range, from this string; you must keep track */
/* of that elsewhere) */
char *log_bin_response = "42@Y40BA00oo000007o0001oP000?h000";
/* Place to temporarily store raw data; 100 bytes is more than enough */
/* for any LOG_BIN? response string */
unsigned char raw_data[100];
/* Decode string into raw data, then convert raw data into usable data */
convert(raw_data, decode(raw_data, log_bin_response));
/* Above global variables now usable; check example LOG_BIN? data */
/* against expected values */
if ((timestamp[0] == 10) && /* Hours */
(timestamp[1] == 24) && /* Minutes */
(timestamp[2] == 29) && /* Seconds */
(timestamp[3] == 10) && /* Month */
(timestamp[4] == 4) && /* Day */
(timestamp[5] == 91) && /* Year */
(misc[0] == 0) && /* Temp units and rate */
(misc[1] == 15) && /* Alarm outputs */
(misc[2] == 255) && /* Digital I/O */
(values[0] == 0.0) && /* Totalizer */
isnan(values[1]) && /* Channel 1 data */
isinf(values[2]) && /* Channel 5 data */
(values[3] == 1.0)) { /* Channel 10 data */
printf("Conversion worked\n");
}
else {
printf("ERROR: conversion did not succeed!\n");
}
exit(0);
}
/* If your math library supplies alternatives to isnan() or isinf(), */
/* use them instead! */
int
isnan(f)
float f;
{
/* This is not portable, or completely accurate (since NaN mantissa */
/* must only be non-zero, and the sign bit can be set), but this works */
/* for NaN values returned by Hydra */
/* Compiler was free to promote to double */
float ff = f;
return ((*(unsigned long *)&ff) == 0x7fc00000L);
}
int
isinf(f)
float f;
{
/* Again, this is not portable, but this time it is accurate */
/* Compiler was free to promote to double */
float ff = f;
return ((*(unsigned long *)&ff) == 0x7f800000L) ||
((*(unsigned long *)&ff) == 0xff800000L);
}
Figure C-3. Example

Table of Contents

Related product manuals