Documentation

UDP Unpack

Unpack a binary byte vector to extract data (not recommended)

Library

Simulink® Real-Time™ Library of Drivers No Longer Recommended for Use

Description

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.

    Note:   The UDP Unpack block will be removed in a future release. Use the Byte Unpacking block instead.

Block Parameters

Output port dimensions

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.

Output port data types

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 usually the same as the Input port data types parameter of the corresponding UDP Pack block.

Byte alignment

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.

Byte Alignment

The byte-alignment feature provided in the Pack and Unpack blocks is primarily intended for interfacing a system running the Simulink Real-Time software to another system running neither Simulink nor Simulink Real-Time 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 Simulink Real-Time systems or between Simulink Real-Time and Simulink systems.)

Even when communication is between the Simulink Real-Time system and a system using a C struct, the use of compiler preprocessor directives 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.

Was this topic helpful?