Reverse little-endian data for big-endian processor
Simulink Support Package for Arduino Hardware/Utilities
Embedded Coder Support Package for STMicroelectronics Discovery Boards/Utilities
Simulink Coder Support Package for STMicroelectronics Nucleo Boards/Utilities
The Byte Reversal block changes the order of the bytes in the input data. Use this block when your process communicates between processors that use different endianness. For example, use this block for communication between Intel® processors that are little-endian and others that are big-endian. Processors compatible with the Intel 80x86 processors and Texas Instruments™ processors are little-endian. In this case, insert a Byte Reversal block before the Byte Pack block and another Byte Reversal block just after the Byte Unpack block.
Using the parameter of this block, you specify the number of block inputs.
Port_1 — First of N input ports
scalar | vector | matrix
Number of input ports specified in the Number of inputs parameter.
The block can have
1 to N input
Port_1 — Output port containing reversed data
scalar | vector
Output ports from
1 to N as
specified in the Number of inputs parameter.
The number of output ports adjusts to match the number of input ports.
Number of inputs — Number of block inputs
The number of input ports and output ports adjusts to match the value specified in this parameter.
When you use more than one input port, each input port maps to the matching output port. Data entering input port 1 leaves through output port 1, and so on. Reversing the bytes does not change the data type.
Suppose that you are sending a signal. The signals have the following attributes:
|Constant value||Type||Byte structure|
Set the number of inputs to 3.
The block creates three input and three output ports.
Connect the signals to the Byte Reversal block.
The following model shows byte reversal. In the first signal,
with value -234, the low-order byte
0001 0110 is
swapped with the high-order byte
1111 1111. Therefore,
the signal outputs to
0001 0110 1111 1111.