| Contents | Index |
Embedded Coder/ Embedded Targets/ Host Communication
Embedded Coder/ Embedded Targets/ Processors/ Texas Instruments C6000/ Target Communication
Simulink Coder/ Desktop Targets/ Host Communication
Using the input port, the block converts data of one or more data types into a single uint8 vector for output. With the options available, you specify the input data types and the alignment of the data in the output vector. Because UDP messages are in uint8 data format, use this block before a UDP Send block to format the data for transmission using the UDP protocol.

Specify the data types for the different signals as part of the parameters. The block supports all Simulink data types except characters. Enter the data types as Simulink types in the cell array, such as 'double' or 'int32'. The order of the data type entries in the cell array must match the order in which the data arrives at the block input. This block determines the signal sizes automatically. The block always has at least one input port and only one output port.
This option specifies how to align the data types to form the uint8 output vector. Select one of the values in bytes from the list.
Alignment can occur on 1, 2, 4, or 8-byte boundaries depending on the value you choose. The value defaults to 1. Given the alignment value, each signal data value begins on multiples of the alignment value. The alignment algorithm s that each element in the output vector begins on a byte boundary specified by the alignment value. Byte alignment sets the boundaries relative to the starting point of the vector.
Selecting 1 for Byte alignment provides the tightest packing, with no holes between any data types for any combination of data types and signals.
Sometimes, you can have multiple data types of varying lengths. In such cases, specifying a 2-byte alignment can produce 1–byte gaps between uint8 or int8 values and another data type. In the pack implementation, the block copies data to the output data buffer 1 byte at a time. You can specify any of the data alignment options with any of the data types.
Use a cell array to enter input data types in the Input port data types parameter. The order of the data types you enter must match the order of the data types at the block input.

In the cell array, you provide the order in which the block expects to receive data—uint32, uint32, uint16, double, uint8, double, and single. With this information, the block automatically provides the number of input ports.
Byte alignment equal to 2 specifies that each new value begins 2 bytes from the previous data boundary.
The example shows the following data types:
{'uint32','uint32','uint16','double','uint8','double','single'}
When the signals are scalar values (no matrices or vectors in this example), the first signal value in the vector starts at 0 bytes. Then, the second signal value starts at 2 bytes, and the third at 4 bytes. Next, the fourth signal value follows at 6 bytes, the fifth at 8 bytes, the sixth at 10 bytes, and the seventh at 12 bytes. As the example shows, the packing algorithm leaves a 1-byte gap between the uint8 data value and the double value.

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 |