Send UDP message
The UDP buffer size is fixed at 8192 bytes and is not configurable.
The UDP Send block transmits an input vector as a UDP message over an IP network port. The remote IP port number to which the block sends the UDP packets is tunable in the C/C++ generated code.
Some Simulink® blocks and
built from models that contain those blocks require shared libraries,
.dll files on Windows®. The UDP
Send block requires the
file. To meet this requirement, follow the example on the
packNGo function page to package the code
files for your model. The resulting compressed folder contains the
that the model requires, including
To run this type of
.exe file outside a MATLAB® environment,
place the required
.dll files in the same folder
.exe file, or place them in a folder on
the Windows system path. For more details, see How To Run a Generated Executable Outside MATLAB.
Specify the IP address or hostname to which the block sends
the message. To broadcast the UDP message, retain the default value,
Specify the port to which the block sends the message. This
parameter is tunable in the C/C++ generated code but not tunable during
simulation. The default is
25000. The value can
be in the range [1 65535].
On Linux®, to set the IP port number below 1024, run MATLAB with root privileges. For example, at the Linux command line, enter:
To let the system automatically assign the port number, select
Automatically determine. To specify the IP port
number using the Local IP port parameter, select
Specify via dialog.
Specify the IP port number from which the block sends the message.
If the receiving address expects messages from a particular port number, enter that number here.
Usage notes and limitations:
The executable generated from this block relies on prebuilt dynamic
library files (
.dll files) included with MATLAB. Use the
packNGo function to package the
code generated from this block and all the relevant files in a compressed
zip file. Using this zip file, you can relocate, unpack, and rebuild your
project in another development environment where MATLAB is not installed. For more details, see How To Run a Generated Executable Outside MATLAB.
The Remote IP port parameter is tunable in the
generated code, but not tunable during simulation. You can control the
parameter tunability in the generated code through several ways. One of the
ways is to configure the parameter as a tunable field of a global structure
in the generated code. Other ways include applying a built-in storage class
or custom storage class to a
Simulink.Parameter object, and
using this object to set the value of the block parameter. For details, see
Create Tunable Calibration Parameter in the Generated Code (Simulink Coder).