Receive data over UDP network from a remote device
Simulink Real-Time / IP
The UDP Receive block receives data over a UDP network from a remote device. It can receive data by using the connection between the development and target computers or by using a dedicated Ethernet card. If you use a dedicated Ethernet card, use the Speedgoat configuration utility to configure the dedicated Ethernet board.
The parameter Local IP address applies when the block executes in a real-time application on a target computer or in a model simulation on a development computer. If your model is running in Simulink® on the development computer, you can use this block to receive data to a remote device. In this case, the Windows® operating system determines the network connection.
Data — Data received
uint8 containing data received over the
UDP network. If no new
packet is received, the data values are held. To determine whether a new
packet has been received, use the Length output
port. If you enable the Enable Simulink messages
parameter, the data type is
UDP_Packet. This data
type consists of:
IP_Address: DataType: uint8, Complexity: real, Dimensions: [4 1]
IP_Port: DataType: uint16, Complexity: real, Dimensions: 1
Length: DataType: uint16, Complexity: real, Dimensions: 1
Data: DataType: uint8, Complexity: real, Dimensions: [75 1]
Length — Number of bytes received
This port is available when you disable the Enable Simulink
messages parameter. The Length is the number of bytes in
the new packet received, otherwise
0. If more bytes
are received than can be output through the receive port with width
defined by Data width, the excess bytes are
Use host-target connection — Use Ethernet connection between development and
'off' (default) |
When you select this parameter, it deactivates the Local
IP address parameter and excludes the ports
5560 from use
Local IP address — Destination IP address for receiving data
When Local IP address is set to
host-target connection, the block uses the connection
between the development and
0.0.0.0 to bind to
which enables the socket to receive broadcast datagrams.
Local port — Destination UDP port to receive data
Specifies UDP port to receive data.
5560 are reserved for Simulink Real-Time
Receive width — Width of
Data output vector
Determines the width of the
Data output vector. If
this value is less than the number of bytes in the received packet, the
excess bytes are discarded.
Receive from any source — Causes receiver to accept data from any IP address
on (default) |
When Receive from any source is
on, the block receives data from
any accessible IP address. When it
off, the block receives data from only the address
that you specify in From IP address.
To make the From IP address parameter visible, clear the Receive from any source check box.
From IP address — Source from which to receive data
Enter a valid IP address as a dotted decimal character vector, for
192.168.7.2. You can also use a MATLAB® expression that returns a valid IP address as a character
255.255.255.255 is an invalid IP
To make this parameter visible, clear the Receive from any source check box.
Enable Simulink messages — Data as messages
off (default) |
The Enable Simulink messages directs the block to treat data as messages. When enabled, the Length port is removed.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Introduced in R2020b