AUTOSAR COM
Packing a signal into a packet
Now the lowest level: which bits of a packet does a signal occupy? Three settings decide it. After this page you can place any signal on the grid by hand.
This is the most detailed lesson of the course. You need it when you compare what COM sends with what a bus tool shows, byte by byte. A packet is called I-PDU in AUTOSAR, and this lesson uses the real setting names from lesson 15.
Four words first
Bit and byte
A bit is a single 0 or 1. A byte is eight bits.
LSB and MSB
In the number 250, the 2 counts most and the 0 least. In bits it is the same: the most significant bit (MSB) counts most, the least significant bit (LSB) counts least.
Byte order
A number longer than one byte must be laid out in some order. Little endian: the least significant byte comes first. Big endian: the most significant byte comes first.
0x…
A number written with 0x in front is hexadecimal, a compact way to write bits: each digit stands for four bits. 0x2A5 is the bits 10 1010 0101.
1. How the bits are numbered
A packet is a row of bytes. AUTOSAR fixes one way of numbering its bits: counting starts at bit 0, the least significant bit of byte 0, and the most significant bit of byte 0 is bit 7. Byte 1 then holds bits 8 to 15, and so on (System Template Table 6.14, TPS_SYST_01068, TPS_SYST_01069).
So PDU bit p lives in byte p / 8 at bit p % 8. Drawn with bit 7 on the left, the numbers run right to left along a row and then jump to the next row. The specification calls this "sawtooth" counting.
2. Three parameters place a signal
| Parameter | Meaning |
|---|---|
ComBitPosition | "Starting position within the I-PDU" (ECUC_Com_00259) |
ComBitSize | Number of bits the signal occupies |
ComSignalEndianness | "Defines the endianness of the signal's network representation": LITTLE_ENDIAN, BIG_ENDIAN or OPAQUE (ECUC_Com_00157) |
The one fact to remember is what "starting position" means. It depends on the byte order:
It denotes the least significant bit for "Little Endian" and the most significant bit for "Big Endian" packed signals within the IPdu.
Little endian: start at the LSB, count up
The signal's least significant bit sits at ComBitPosition. Each more significant bit takes the next higher PDU bit number. A 10-bit signal at position 5 occupies bits 5 to 14.
Big endian: start at the MSB, walk right, drop a row
The signal's most significant bit sits at ComBitPosition. Each less significant bit takes the cell to the right. When you run off the right edge (bit 0 of a byte), continue at bit 7 of the next byte. A 10-bit signal at position 5 occupies bits 5, 4, 3, 2, 1, 0 and then 15, 14, 13, 12.
In both cases the significance of bits inside any one byte is unchanged: a higher bit number in a byte is always the more significant bit. Byte order only decides which byte gets the significant end (System Template §6.2.2).
3. See it
This is the System Template's own example (10 bits, start position 5, Example 6.10), with the value 0x2A5. Switch the endianness and watch the same ten bits move. Then change position and size until nothing surprises you.
Each cell shows its PDU bit number, the bit's value, and which signal bit it carries (s0 is the signal's LSB).
4. Do it
Now without the picture. Read the configuration, click every cell the signal occupies, then check. Every task crosses a byte boundary.
What you can do now. Three in a row on the first try means you can read a signal's place in the packet straight from its settings.
Check yourself
Optional. Answer from memory.
Sources: AUTOSAR System Template, R25-11, section 6.2.2 and Table 6.14, with the original drawings in Figures 6.10 and 6.11; AUTOSAR COM specification, R25-11, section 7.1.3. Cheat sheet: Signal packing.