Fluke Hydra Series II User Manual page 242

Data bucket
Table of Contents

Advertisement

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();
extern void convert();
/* 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) &&
(timestamp[1] == 24) &&
(timestamp[2] == 29) &&
(timestamp[3] == 10) &&
(timestamp[4] == 4) &&
(timestamp[5] == 91) &&
(misc[0]
== 0) &&
(misc[1]
== 15) &&
(misc[2]
== 255) &&
(values[0]
== 0.0) &&
isnan(values[1]) &&
isinf(values[2]) &&
(values[3]
== 1.0)) {
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);
}
/* ASCII to binary decoding */
/* Convert Hydra binary to usable types */
/* Hours
/* Minutes
/* Seconds
/* Month
/* Day
/* Year
/* Temp units and rate */
/* Alarm outputs
/* Digital I/O
/* Totalizer
/* Channel 1 data
/* Channel 5 data
/* Channel 10 data
Figure C-3. Example
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/
*/

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

2635a

Table of Contents