Main Content

FIFO Read Binary

Read multiple binary data streams according to header information

Since R2020b

  • FIFO Read Binary block

Libraries:
Simulink Real-Time / RS232

Description

The FIFO Read Binary block reads multiple binary headers from a FIFO.

This block identifies and separates data by finding unique byte sequences (headers) that mark the data. Each header indicates the start of a fixed-length binary message. If the same header arrived in the FIFO more than once since the block was last executed, the block discards the older data. It then returns the latest instance of the header. The block catches up with data that arrives faster than the block executes.

Example models slrt_ex_serialbaseboardbinarytest and slrt_ex_serialbaseboardbinarysplit show how to use the FIFO Read HDRS block. To find and open these models, in the MATLAB® Command Window, type:

modelfinder('slrealtime')

Ports

Input

expand all

Connects to the software FIFO containing data read from the serial port.

If true, read from FIFO.

Dependency

To make this port visible, set parameter Enable input.

Output

expand all

Vectors containing the parsed data read from the FIFO. Each output corresponds to one of the headers.

Dependency

To determine the data type of this vector, set the parameter Output vector type.

Data Types: int8 | uint8 | int16 | uint16 | int32 | uint32

Parameters

expand all

Enter the headers that you want the block to look for in a block of data from the FIFO. Enter each header as an element in a cell array either as a quoted character vector or a concatenation with char(val) for non-printable byte patterns.

Programmatic Use

Block Parameter: hdr

Enter the message length, in bytes. Include the header in the length.

Programmatic Use

Block Parameter: lengths

From the list, select the behavior of the block if the FIFO has not received new data:

  • Hold last output if no new data — Block keeps the output from the last FIFO message.

  • Zero output if no new data — Block overwrites the first element of the output with 0.

Programmatic Use

Block Parameter: hold

To create an input port that enables or disables the read operation, select this check box. The input port takes a Boolean signal.

Dependency

Causes input port E to become visible.

Programmatic Use

Block Parameter: enable

Specify the maximum number of characters for this block to return. The resulting vector size is one more than this maximum number of characters. This block indicates the number of characters being returned by using the extra element as:

  • A NULL terminator for the 8-bit data types

  • The character count for the 16-bit and 32-bit data types

Enter a large enough number. If this number is too small, the block cannot return anything. For example, if you enter the value 10, but on execution the FIFO contains 11 characters plus the null terminator, the block does not return any characters. If it contains 5, the block returns 5 characters plus the NULL terminator.

Programmatic Use

Block Parameter: maxsize

The 8-bit data types produce a NULL-terminated character vector in the output vector. For 16-bit and 32-bit data types, the first element contains the number of elements to expect in the rest of the output vector.

Programmatic Use

Block Parameter: outputtype

Enter the base sample time or a multiple of the base sample time. -1 means that sample time is inherited.

Programmatic Use

sampletime

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2020b