Send data over UDP network to a remote device
The UDP Send block sends data over a UDP network to a remote device. The block can send 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.
To broadcast to all
devices, set To IP address to
otherwise set To IP address to a valid IP address.
Data— Data to transmit
uint8 containing data to transmit
over the UDP network. To determine how many bytes of data to transmit,
use the Length input port.
Length— Number of bytes of data to transmit
Determines the number of bytes of data to transmit. Specify
the width of the
Data vector as the maximum number
of bytes that you expect to transmit.
Local IP address— Source IP address for sending 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— Source UDP port through which to transmit data
Specifies local UDP port through which to transmit data.
−1 means that the block
transmits using any available port.
To IP address— IP address of target device
Specifies IP address of target device. To broadcast, send to
To port— UDP port of target device
Specify the UDP port of target device. With To IP address, this parameter defines the destination of the data transmission.
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,