| Contents | Index |
xPC Target Library for UDP
This block is the exact analog of the Pack block. It receives a vector of uint8 and outputs various Simulink data types in different sizes. The Pack block is on the sending side and the Unpack block is on the receiving side in different models.

Contains a cell array, with each element the dimension returned by the MATLAB size function of the corresponding signal. This should normally be the same as the dimensions of the signals feeding into the corresponding Pack block.
Specify the data types for the different signals as part of the block parameters. The supported data types are double, single, int8, uint8, int16, uint16, int32, uint32, and boolean. This parameter is the same as the Input port data types parameter of the matching UDP Pack block.
The byte alignment field specifies how the data types are aligned. The possible values are: 1, 2, 4, and 8. The byte alignment scheme is simple, and starts each element in the list of signals on a boundary specified by the alignment relative to the start of the vector.

As shown in the figure above, the Output port datatypes field is the same as the Input port data types field of the matching Pack block.
The byte-alignment feature provided in the Pack and Unpack blocks is primarily intended for interfacing a system running the xPC Target software to another system running neither Simulink nor xPC Target software. For example, the data on the other end might be in the form of a C struct, which is subject to the byte-alignment convention of the compiler used. You should use a byte-alignment value of 1 (tightly packed) if the source and target data formats permit it. (This is easily accomplished when UDP I/O is used to exchange data between two xPC Target systems or between xPC Target and Simulink systems.)
Even when communication is between the xPC Target system and a system using a C struct, the use of compiler pragmas might help to pack the structure tightly. For example, #pragma pack(1) is common to several compilers. The byte-alignment blocks are provided for cases when this is not possible.

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |