uint8 vector as UDP message
The UDP Receive block receives UDP packets from an IP network port and saves them to its buffer. With each sample, the block outputs the contents of a single UDP packet as a data vector. The local IP port number on which the block receives the UDP packets is tunable in the C/C++ generated code.
The generated code for this block relies on prebuilt
You can run this code outside the MATLAB® environment, or redeploy
it, but you must account for these extra
when doing so. The
packNGo function creates a
single zip file containing all of the
pieces required to run or rebuild this code. For more details, see How To Run a Generated Executable Outside MATLAB.
Specify the IP port number on which to receive UDP packets.
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].
Note: On Linux®, to set the IP port number below 1024, run MATLAB with root privileges. For example, at the Linux command line, enter:
'to accept all)
Specify the IP address from which to accept packets. Entering
a specific IP address blocks UDP packets from other addresses. To
accept packets from any IP address, enter
This value defaults to
Make the receive buffer large enough to avoid data loss caused
by buffer overflows. This value defaults to
Specify the maximum length, in vector elements, of the data
output vector. Set this parameter to a value equal or greater than
the data size of a UDP packet. The system truncates data that exceeds
this length. This value defaults to
If you disable Output variable-size signal, the block outputs a fixed-length output the same length as the Maximum length for Message.
Set the data type of the vector elements in the Message output.
Match the data type with the data input used to create the UDP packets.
This option defaults to
If your model supports signals of varying length, enable the Output variable-size signal parameter. This checkbox defaults to selected (enabled). In that case:
The output vector varies in length, depending on the amount of data in the UDP packet.
The block emits the data vector from a single unlabeled output.
If your model does not support signals of varying length, disable the Output variable-size signal parameter. In that case:
The block emits a fixed-length output the same length as the Maximum length for Message.
If the UDP packet contains less data than the fixed-length output, the difference contains invalid data.
The block emits the data vector from the Message output.
The block emits the length of the valid data from the Length output.
The block dialog box displays the Data type for Length parameter.
In both cases, the block truncates data that exceeds the Maximum length for Message.
Set the data type of the Length output. This option defaults
For each sample, wait this length of time for a UDP packet before
returning control to the scheduler. This value defaults to
which indicates to wait indefinitely.
Note: This parameter appears only in the Embedded Coder® UDP Receive block.
Specify how often the scheduler runs this block. Enter a value greater than zero. In real-time operation, setting this option to a large value reduces the likelihood of dropped UDP messages. This value defaults to a sample time of 0.01 s.
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 Local 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
and using this object to set the value of the block parameter. For
details, see Block Parameter Representation in the Generated Code (Simulink Coder).