Receive data over UDP network from a remote device
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, add a UDP Configure block to your model.
The parameter Local IP address applies only when the block executes on a target computer. If your model is running in Simulink® on the development computer, you can use this block to transmit 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
Length— Number of bytes received
Number of bytes in the new packet received, otherwise
If more bytes are received than can be output through the receive
port with width defined by Receive width, the
excess bytes are discarded.
Local IP address— Destination IP address for receiving data
Use host-target connection(default)
When Local IP address is set to
host-target connection, the block uses the connection
between the development and target computers. Otherwise, the block
uses the value that you set in the Local IP address parameter
of the UDP Configure block.
Local port— Destination UDP port through which to receive data
Specifies UDP port through which to receive data.
Receive width— Width of
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
When Receive from any source is
the block receives data from any
accessible IP address. When it is
off, the block
receives data from only the address that you specify in From
To make the From IP address parameter visible, clear Receive from any source.
From IP address— Source from which to receive data
Enter a valid IP address as a dotted decimal character vector,
10.10.10.3. You can also use a MATLAB® expression
that returns a valid IP address as a character vector.
The default address,
0.0.0.0, causes the
block to accept UDP packets from any
accessible device. If you set From IP address to
a specific IP address, only packets arriving from that IP address
255.255.255.255 is an invalid
To make this parameter visible, clear Receive from any source.
Sample time (-1 for inherited)— Sample time of block
-1(default) | numeric
Enter the base sample time or a multiple of the base sample time.
This example shows how to use UDP blocks to send data from a target computer to a development computer. Signal data are sent by the transmit model running on the target computer,
TargetToHostUDPTx, to the receiver model running in Simulink® on the development computer,