Anyone working in embedded development is familiar with data endianness issues. If left unaddressed, they can lead to a range of errors.

What are some common endianness modes?
Each system and device may use a different endianness mode.
For example, x86-based computers and STM32 microcontrollers use little-endian mode, while some network protocols (such as TCP/IP) and some PLCs (such as the Siemens S7-300 and S7-400) use big-endian mode.
How to Address Data Endianness Issues
In embedded development, addressing data endianness issues requires appropriate measures.
Example 1:
Reading register data from a Mitsubishi PLC via the Modbus protocol. The Mitsubishi PLC uses little-endian mode, while the Modbus protocol uses big-endian mode for data transmission. Therefore, when acquiring data on the STM32, the received big-endian data must be converted to little-endian mode before storage.
Example 2:
When transmitting data to a Windows client via HTTP, because Windows uses little-endian format, while network transmission uses big-endian format, the little-endian data must be converted to big-endian format before sending. After receiving the data, the big-endian data must be converted back to little-endian format.

Using Float data as an example:
When acquiring data on the STM32, the data from two 16-bit registers must be combined into a 32-bit Float data, which is then converted into a big-endian byte stream for transmission. After receiving the data on the Windows client, the big-endian byte stream is converted into a little-endian Float data. If transmitting int data, whether 16-bit or 32-bit, similar endian conversion is required.