2635A
Users Manual
C-6
/* Import globals from main program */
extern int timestamp[];
extern int misc[];
extern float values[];
/*
-* convert(): Convert a LOG_BIN? array of binary data into useful data
**
** Converts BCD values to integer, raw floating point values into float
** values usable under the Intel x86 (IBM PC) architecture.
**
** Inputs:
** src Array of binary data, from LOG_BIN? query
** length Number of bytes in src array
**
** Outputs:
** timestamp[] Set to decimal timestamp values
** misc[] Set to temp units, rate, and digital I/O values
** values[] Set to floating point values found in binary data
** (must be room for a maximum of 22 floats)
*/
void
convert(src, length)
unsigned char *src;
int length;
{
unsigned char *m;
int n;
/* Convert timestamp from BCD to decimal */
for (n=0; n < 6; n++, src++) {
/* Binary Coded Decimal (BCD) format, packs the upper nibble as the
*/
/* tens digit, the lower nibble as the ones digit. Convert this
*/
/* into an integer number.
*/
timestamp[n] = (10 * (*src >> 4) + (*src & 0x0f));
}
/* Save temperature units, measurement rate, and digital I/O values */
for (n=0; n < 3; n++) {
misc[n] = *src++;
}
/* Convert raw measurement data into floating point */
m = (unsigned char *)values;
for (length -= 9; length > 3; length -= 4) {
#ifdef sun
/* SunOS architecture (also works for Motorola CPUs) */
*m++ = src[0];
*m++ = src[1];
*m++ = src[2];
*m++ = src[3];
#else
/* Assume Intel x86 architecture */
*m++ = src[3];
*m++ = src[2];
*m++ = src[1];
*m++ = src[0];
#endif
src += 4;
}
}
Figure C-2. Floating_Point Conversion
Содержание 2635A
Страница 8: ...2635A Users Manual vi...
Страница 26: ...2635A Users Manual xxiv...
Страница 29: ...Preparation for Use Introduction 1 1 3...
Страница 50: ...2635A Users Manual 1 24...
Страница 53: ...Front Panel Operations Summary of Front Panel Operations 2 2 3...
Страница 88: ...2635A Users Manual 2 38...
Страница 180: ...2635A Users Manual 5 10...
Страница 212: ......
Страница 234: ...2635A Users Manual B 4...
Страница 250: ...2635A Users Manual D 8...
Страница 251: ...E 1 Appendix E 8 Bit Binary Coded Decimal Table...
Страница 264: ...Hydra Memory Card Record DATA FILES SET UP FILES DATxx Application Note SETxx Application Note...
Страница 268: ...2635A Users Manual 4...