Command and response strings: examples, Endianness, Big-endian numbers – Welch Allyn SureTemp PlusModule - User Manual User Manual

Page 55: Little-endian numbers, Ieee 754 data format

Advertising
background image

SureTemp Plus Module OEM Implementation

Communications Protocol

Welch Allyn OEM Technologies

Confidential 55

Command and Response Strings: Examples

This section provides examples of command and response strings for some of the more
commonly used commands. It also provides a brief description, with examples, of endianness.

Endianness

Big-Endian Numbers

In big-endian machines—typical of Motorola® processors—the high-order byte is first:

Command Code (Word): 0x94 0x1C = 0x941C

Little-Endian Numbers

In little-endian machines—typical of Intel® processors—the low-order byte is first:

Byte Count (Word): 0x13 0x00 = 0x0013.

In IEEE 754 little-endian floating-point numbers, the least-significant byte is first:

IEEE 754 Data Format

The IEEE 754 floating-point data format consists of four contiguous bytes: a 23-bit signed binary
mantissa and an 8-bit biased binary exponent:

Converting a String of Bytes to a Floating-Point Number

1. Swap the bytes to the endian format used by processor on which the software is running.

2. In C, cast the number to a float

Decimal

Hexadecimal

100.0

00 00 C8 42

-100.0

00 00 C8 C2

0.5

00 00 00 3F

-1.75

00 00 E0 BF

0.56

29 5C 0F 3F

0.0625

00 00 80 3D

Bits

Description

0

Sign of the mantissa (0 = positive; 1 = negative)

1 - 8

Exponent (8-bit unsigned value)

(The implied binary point is between bits 8 and 9.)

9 - 31

Mantissa

Advertising