Receive, Message Receive

Extract data from received messages

  • Library:
  • Simulink / Messages & Events

    SimEvents

Description

The Send block extracts data from received messages and writes them to the output signal port. If there are no new messages when the block executes, the block uses the Value source when queue is empty value. Receive and Message Receive blocks are identical blocks.

  • Select Hold last value to hold data read from the last message.

  • Select Use initial value to write default data.

Ports

Input

expand all

The input port for the message.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | enumerated | bus | fixed point

Output

expand all

Outputs 1 if the block receives a message successfully, and 0 otherwise.

Dependencies

To enable this port, select the check box labeled Show receive status.

Data Types: double

Output port for the signal.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | enumerated | bus | fixed point

Parameters

expand all

Select this check box if you use an internal queue to receive messages.

Programmatic Use

Block Parameter: UseInternalQueue
Type: character vector
Values: 'on' | 'off'
Default: 'on'

Select this check box to choose between two queue overwriting policies.

  • If you select the check box, an incoming message overwrites the oldest if the queue is full.

  • If you clear the check box, the block does not accept new messages if the queue is full.

Dependencies

This parameter is visible when you select the box labeled Use internal queue.

Programmatic Use

Block Parameter: QueueOverwriting
Type: character vector
Values: 'on' | 'off'
Default: 'on' (for Simulink) and 'off' (for SimEvents)

Specify message queue capacity.

Dependencies

This parameter is visible when you select the box labeled Use internal queue.

Programmatic Use

Block Parameter: QueueLength
Type: character vector
Values: '16' | scalar
Default: '16'

The block supports three message sorting policies:

  • First-in-first-out (FIFO) — The oldest message in the storage departs first.

  • Last-in-first-out (LIFO) — The newest message in the storage departs first.

  • Priority — Messages or entities are sorted based on their priority

    The priority queue can be used only when the Overwrite the oldest element if queue is full check box is cleared.

    Note

    Priority queue does not support fixed point data type.

Dependencies

This parameter is visible when you select the box labeled Use internal queue.

Programmatic Use

Block Parameter: QueueType
Type: character vector
Values: 'FIFO' | 'LIFO' | 'Priority'
Default: 'FIFO'

Choose the direction of sorting messages based on priority.

  • Ascending — Messages with smaller priority values appear in front of the queue.

  • Descending — Messages with greater priority values appear in front of the queue.

Dependencies

This parameter is visible when you select the box labeled Use internal queue andQueue type > Priority.

Programmatic Use

Block Parameter: PriorityOrder
Type: character vector
Values: 'Ascending' | 'Descending'
Default: 'Ascending'

Select this check box to show whether a message was received. If this check box is selected the block outputs 1 if it receives a message successfully, and 0 otherwise.

Programmatic Use

Block Parameter: ShowQueueStatus
Type: character vector
Values: 'on' | 'off'
Default: 'off'

Enter an initial data value for the queue before the arrival of the first message. The default value [](unspecified) is treated as 0 with data type double.

Programmatic Use

Block Parameter: InitialValue
Type: character vector
Values: '[]' | scalar
Default: '[]'

Specify the value to receive when received message queue is empty.

  • Hold last value (default) — Holds data read from the last message.

    Initially, if the block tries to receive a message and fails, it outputs the initial value.

  • Use initial value — Writes default data.

Dependencies

This parameter is visible when you select the box labeled Use internal queue.

Programmatic Use

Block Parameter: ValueSourceWhenQueueIsEmpty
Type: character vector
Values: 'Hold last value' | 'Use initial value'
Default: 'Hold last value'

To inherit the sample time, set this parameter to -1. See Specify Sample Time for more information.

Programmatic Use

Block Parameter: SampleTime
Type: character vector
Values: '-1' | scalar
Default: '-1'

Block Characteristics

Data Types

Boolean | bus | double | enumerated | fixed point | integer | single | string

Direct Feedthrough

no

Multidimensional Signals

yes

Variable-Size Signals

no

Zero-Crossing Detection

no

Extended Capabilities

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

See Also

Introduced in R2016a