code8230
code8230

Reputation: 57

Bit/Byte adressing - Little/Big-endnian

Consider the 16-Bit data packet below, which is sent through the network in network byte order ie Big Endian:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 (Byte num)
34 67 89 45 90 AB FF 23 65 37 56 C6 56 B7 00 00 (Value)

Lets say 8945 is a 16 bit value. All others are 8 bit data bytes.

On my system, which is little endian, how would the data be received and stored?

Lets say, we are configured to receive 8 bytes at a time. RxBuff is the Rx buffer where data will be received.

Buff is the storage buffer where data would be stored.

Please point out which case is correct for data storage after reading 8 bytes at a time: 1) Buff[] = {0x34, 0x67, 0x45, 0x89, 0x90, 0xAB....... 0x00};

2) Buff[] = {0x00, 0x00, .......0x67, 0x89, 0x45, 0x34};

Would the whole 16 bytes data be reversed or only the 2 bytes value contained in this packet?

Upvotes: 2

Views: 107

Answers (1)

tomahh
tomahh

Reputation: 13651

Only the 2 bytes value contained in the packet will be reversed.
Endianess concern byte order, and not bit order.

This is explain on wikipedia

Upvotes: 2

Related Questions