Frame Layout - Little or Big Endian

A CAN frame consists of three sections:

  • Identifier
  • Data
  • Data length code

An identifier can be of standard or extended type or can be a remote transmission request.

To differentiate the types the following addition to the identifier is implemented:

  •  bit31: reserved (always 0)
  •  bit30: marks a remote transmission request (1=rtr, 0=data frame)
  •  bit29: marks an extended identifier (1=extended, 0=standard)
  •  bit28-0: the identifier (standard or extended)

Note: The layers dont use of bit 29 and bit 30, but this bits can be useful in callback- or hook-functions.

The functions CanFrmGet/Set support little or big endianess for bit- and byte-granularity. How bytes are ordered in both formats is well defined, therefore this chapter outlines only the formats for BIT-granularity of signals.

As an example for little endian format we have a 32 bit signal which starts at bit 29 in a 8 byte CAN msg:If we set the signal to 0x12345678 an send the CAN message with all other bits set to 0, we will receive a CAN message with 8 data bytes: 00 00 00 00 CF 8A 46 02.

If we look a the last 5 bytes in bit-format:

Bytes

3

4

5

6

7

Hex

0

0

C

F

8

A

4

6

0

2

Bits

0000

0000

1100

1111

1000

1010

0100

0110

0000

0010

The red-colored bits are not part of the signal and can be dismissed.As an example for big endian format we have a 32 bit signal which also starts at bit 29 in a 8 byte CAN msg:If we set the signal to 0x12345678 an send the CAN message with all other bits set to 0, we will receive a CAN message with 8 data bytes: 00 00 00 00 48 D1 59 E0.

If we look a the last 5 byte in bit-format:

Bytes

3

4

5

6

7

Hex

0

0

4

8

D

1

5

9

E

0

Bits

0000

0000

0100

1000

1101

0001

0101

1001

1110

0000

Shift the bits 2 times to the right and you will get the signal value back:

Hex

0

1

2

3

4

5

6

7

8

0

Bits

0000

0001

0010

0011

0100

0101

0110

0111

1000

0000