National Instruments 372139B-01 Automobile User Manual


 
Chapter 6 Automotive Diagnostic Command Set API for C
© National Instruments Corporation 6-15 Automotive Diagnostic Command Set User Manual
ndConvertToPhys
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
gives the start byte of the binary representation in the dataIn record.
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)