UDP Communication Setup
The infrastructure provided in the Simulink® Real-Time™ Library for UDP communication consists of two blocks: a UDP Send block and a UDP Receive block. These blocks are in the Simulink Real-Time Library, available from the Simulink Library under Simulink Real-Time. You can also access them from the MATLAB® command line by typing:
slrealtimelib
The blocks are located under the IP
heading in the library. The
UDP Send block takes as input a vector of type
uint8
. The UDP Receive block outputs a vector of
uint8
. To convert arbitrary Simulink data types into this vector of uint8
, use a Byte
Packing block. To convert a vector of uint8
s back into
arbitrary Simulink data types, use a Byte Unpacking block.
If you are using a dedicated Ethernet port for UDP communication, use the Speedgoat Ethernet Configuration utility to configure the dedicated Ethernet board. For more information, see Troubleshoot Model Upgrade for R2020b.
To communicate with big-endian architecture systems, use the Byte Reversal/Change Endianess block. Your model does not need this block for communicating between 80x86-based computer systems running either the Simulink Real-Time RTOS or the Microsoft® Windows® operating system.
The blocks work from within the Simulink environment and from a real-time application running under the Simulink Real-Time system. Be careful about transmitting data between a Simulink simulation and a real-time application or using two Simulink models. A Simulink model is not a real-time model and can run several times faster or slower than a real-time application. Set the sample time of the UDP Send and UDP Receive blocks and the sample time of the Simulink model so that the blocks can communicate.
You cannot configure two UDP Receive blocks with the same local port. For example, two UDP Receive blocks cannot have the same local port and different IP addresses.
You cannot configure two UDP Send blocks with the same local port. For example, two UDP Send blocks cannot have the same local port and different IP addresses.