Ndconvertfromphys, Ndconvertfromphys -13, Purpose – National Instruments CAN 372139B-01 User Manual

Page 177: Format, Input

Advertising
background image

Chapter 6

Automotive Diagnostic Command Set API for C

© National Instruments Corporation

6-13

Automotive Diagnostic Command Set User Manual

ndConvertFromPhys

Purpose

Converts a physical data value into a binary representation using a type descriptor.

Format

void ndConvertFromPhys(

TD2 *typeDescriptor,

double value,

unsigned char dataOut[],

long *len);

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

)

value

The physical value to be converted to a binary representation.

Advertising