FIFO Read
Libraries:
Simulink Real-Time /
RS232
Description
The FIFO Read block is the read side of a FIFO read/write pair. You use this block to parse simple data streams. The block functions in two modes that you set by using the Read to delimiter check box.
If you select the Read to delimiter check box, the block reads only elements if the specified delimiter has been written to the FIFO Write block. If the delimiter is found, the block returns elements up to and including the delimiter in the output vector. If the delimiter is not found, the block returns a zero-length vector, as determined by the data type. (If you have a zero-length vector, you can have your model perform a particular operation or ignore the case.)
If you clear the Read to delimiter check box, the block returns elements between Minimum read size and the smaller of the number of elements currently in the FIFO and Maximum read size.
When performing ASCII reads, select the Read to delimiter check box. When performing binary reads, clear this check box.
Here are some examples of how you can set up the FIFO Read block:
Transmit side of the interrupt service routine — If the interrupt reason is not an empty hardware FIFO on the UART, the maximum input port receives a value of
0
. If the hardware FIFO is empty, it receives the size of the hardware FIFO. The minimum input port receives the constant value of1
.Receive side of the interrupt service routine — The typical case with ASCII data has the minimum and maximum input ports disabled. The Read to delimiter parameter check box is selected and the Delimiter parameter has the value of carriage return or line feed. The value of the Maximum read size parameter is large (along the order of the FIFO size) and the value of Minimum read size parameter is 1. In this form, the driver acts like a nonblocking read line.
An alternate receive-side configuration for fixed-length binary blocks of data has the value of the Maximum read size and Minimum read size parameters set to the fixed length of the block. The Read to delimiter parameter is not selected.
For complex data streams, consider using the FIFO Read HDRS and FIFO Read Binary blocks. For guidelines on when to use these blocks, see RS-232 FIFO Read Blocks.
For more information, see RS-232 Serial Communication and RS-232 Legacy Drivers.
Examples
Ports
Input
Output
Parameters
Extended Capabilities
Version History
Introduced in R2020b