Purpose

Converts a binary representation of a value into its physical value using a type descriptor.

Format

        void ndConvertToPhys(
       TD2 *typeDescriptor,
       unsigned char dataIn[],
       long len,
       double *value);
      

Input

typeDescriptor

A struct that specifies the conversion of the physical value to its binary representation:

             typedef struct {
        long StartByte;
        long ByteLength;
        unsigned short ByteOrder;
        unsigned short DataType;
        double ScaleFactor;
        double ScaleOffset;
        } TD2;
      

StartByte is ignored by ndConvertFromPhys.

ByteLength is the number of bytes in the binary representation.

ByteOrder defines the byte order for multibyte representations. The values are:

0: MSB_FIRST (Motorola)

1: LSB_FIRST (Intel)

DataType is the binary representation format:

0: Unsigned. Only byte lengths of 1–4 are allowed.

1: Signed. Only byte lengths of 1–4 are allowed.

2: Float. Only byte lengths 4 or 8 are allowed.

ScaleFactor defines the physical value scaling:

Phys = (ScaleFactor) * (binary representation) + (ScaleOffset)

ScaleOffset (refer to ScaleFactor)

dataIn

Points to the byte array that contains the binary representation of value.

len

Must contain the dataIn array length. Output

value

The physical value converted from the binary representation. Description

Data output from diagnostic services (for example, ndReadDataByLocalIdentifier) is usually a byte stream of binary data. If you have a description of the data output (for example, byte 3 and 4 are engine RPM scaled as .25 * x RPM in Motorola representation), you can use ndConvertToPhys to extract the physical value from the byte stream by filling an appropriate typeDescriptor struct.