Receive messages
Simulink / Messages & Events
SimEvents
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.
Port_1
— Input messageThe input port for the message.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| enumerated
| bus
| fixed point
Port_S
— Show whether a message was receivedOutputs 1
if the block receives a message
successfully, and 0
otherwise.
To enable this port, select the check box labeled Show receive status.
Data Types: double
Port_1
— Output signalOutput port for the signal.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| Boolean
| enumerated
| bus
| fixed point
Use internal queue
— Select to use an internal queueSelect this check box if you use an internal queue to receive messages.
Block Parameter:
UseInternalQueue |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'on' |
Overwrite the oldest element if queue is full
— Specify queue overwriting policySelect 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.
This parameter is visible when you select the box labeled Use internal queue.
Block Parameter:
QueueOverwriting |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'on' (for Simulink) and 'off' (for SimEvents) |
Queue length
— Specify the length of the message queue16
(default) | scalar
Specify message queue capacity. The queue length can be specified as a
positive integer between 1
and 226-1 (both included).
This parameter is visible when you select the box labeled Use internal queue.
Block Parameter:
QueueLength |
Type: character vector |
Values: '16'
| scalar |
Default:
'16' |
Queue type
— Specify message queue sorting policyFIFO
(default) | LIFO
| Priority
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.
This parameter is visible when you select the box labeled Use internal queue.
Block Parameter:
QueueType |
Type: character vector |
Values:
'FIFO' | 'LIFO' |
'Priority' |
Default:
'FIFO' |
Priority order
— Specify message queue priorityAscending
(default) | Descending
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.
This parameter is visible when you select the box labeled Use internal queue andQueue type > Priority.
Block Parameter:
PriorityOrder |
Type: character vector |
Values:
'Ascending' | 'Descending'
|
Default:
'Ascending' |
Show receive status
— Show whether a message was receivedoff
(default) | onSelect 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.
Block Parameter:
ShowQueueStatus |
Type: character vector |
Values: 'on'
| 'off' |
Default:
'off' |
Initial value
— Set initial data value[](unspecified)
(default) | scalar
| vector
| matrix
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 Signals.
Block Parameter:
InitialValue |
Type: character vector |
Values: '[]'
| scalar |
Default:
'[]' |
Value source when queue is empty
— Value source for empty queueHold last value
(default) | Use initial value
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.
This parameter is visible when you select the box labeled Use internal queue.
Block Parameter:
ValueSourceWhenQueueIsEmpty |
Type: character vector |
Values: 'Hold last
value' | 'Use initial value'
|
Default: 'Hold last
value' |
Sample time (-1 for inherited)
— Specify the time interval between samples-1
(default) | scalar
To inherit the sample time, set this parameter to -1
.
See Specify Sample Time for
more information.
Block Parameter:
SampleTime |
Type: character vector |
Values: '-1'
| scalar |
Default:
'-1' |
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|