Main Content

Receive

Receive messages

  • Receive block

Libraries:
Simulink / Messages & Events
SimEvents

Alternative Configurations of Receive Block:
Message Receive

Description

The Receive 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.

Examples

Ports

Input

expand all

The input port for the message.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | 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 | int64 | uint8 | uint16 | uint32 | uint64 | 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. The queue length can be specified as a positive integer between 1 and 226-1 (both included).

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 accepts only non-bus scalar and it 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.

To use this block to initialize a nonvirtual bus signal, specify the initial value as a MATLAB® structure. For more information about initializing nonvirtual bus signals using structures, see Specify Initial Conditions for Bus Elements.

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

Alternative Configurations

expand all

The Message Receive block selects the Use internal queue parameter, sets Queue type to FIFO and Queue length to 16.

Libraries:
Simulink / Messages & Events
SimEvents

Extended Capabilities

Version History

Introduced in R2016a

See Also

(SimEvents)