This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Message Receive

Extract data from received messages

  • Library:
  • SimEvents

Description

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

  • 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

Output

expand all

Output port for the signal.

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

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

Dependencies

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

Data Types: double

Parameters

expand all

Specify message queue length.

Programmatic Use

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

Choose the queue type.

  • FIFO — First-in-first-out

  • LIFO — Last-in-first-out

  • Priority — Store the entities in order of priority

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 Queue type > Priority.

Programmatic Use

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

Select this check box to show the status of the queue.

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.

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 (Simulink) for more information.

Programmatic Use

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

Block Characteristics

Data Types

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

Multidimensional Signals

Yes

Variable-Size Signals

No

Extended Capabilities

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

Introduced in R2016a