| Contents | Index |
xPC Target Library for UDP
The Pack block is used to convert one or more Simulink signals of varying data types to a single vector of uint8 as required by the Send 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. The block determines the sizes of the signals automatically.
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 seen in the figure above, the data types of each of the signals must be specified as a cell array of strings in the required order. Once this is done, the block automatically converts itself to one with the corresponding number of input ports. There is always one output port. For example, say the Input port data types are specified as
{'uint8','uint32','single','int16','double'}and an alignment of 4 is used. Assume also that all the signals are scalars. The first signal then starts at byte 0 (this is always true), the second at byte 4, the third at byte 8, the fourth at byte 12, and the fifth at byte 16. Note that the sizes of the data types used in this example are 1, 4, 4, 2, and 8 bytes respectively. This implies that there are "holes" of 3 bytes between the first and second signal and 2 bytes between the fourth and fifth signal.
A byte alignment of 1 means the tightest possible packing. That is, there are no holes for any combination of signals and data types.
Note Individual elements of vector/matrix signals are not byte aligned: only the entire vector/matrix is byte aligned. The individual elements are tightly packed with respect to the first element. |

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 |