User`s guide

User Datagram Protocol (UDP)
3-23
data on the other end may be in the form of a C struct, which is subject to the
byte alignment convention of the compiler used. We recommend using a byte
alignment value of 1 (tightly packed) whenever possible. This, of course, is
easily accomplished when UDP I/O is used to exchange data between two xPC
Target systems or between xPC Target and Simulink.
Even when communication is between xPC Target and a system using a C
struct, the use of compiler pragmas may help to pack the structure tightly. For
example,
#pragma pack(1) is common to several compilers. The byte
alignment blocks are provided for the case when this is not possible. We provide
an example later for the case of a C structure, where several pack and unpack
blocks are used to force the proper alignment of data.
UDP Byte Reversal Block.
You use the Byte Reversal block for communication between an xPC Target
system and a system running with a processor that is big-endian. Processors
compatible with the Intel 80x86 family are always little-endian. For this
situation, you should insert a Byte Reversal block before the Pack block and
just after the Unpack block to ensure that the values are transmitted properly.
This block takes just one parameter, the number of inputs. The number of
input ports adjusts automatically to follow this parameter, and the number of
outputs is equal to the number of inputs.
UDP Example
In this section, we provide an example of how to set up two way data exchange
between two xPC Target systems, between xPC Target and Simulink, or