UDP Receive
Receive UDP data from remote host
Add-On Required: This feature requires the Embedded Coder Support Package for ARM Cortex-A Processors add-on.
Libraries:
Embedded Coder Support Package for ARM Cortex-A Processors
Description
The UDP Receive block receives UDP (User Datagram Protocol) data from a remote host. The block reads available UDP data from the socket buffer and outputs the data as a vector.
Examples
Get Started with Embedded Coder Support Package for ARM Cortex-A Processors
Use Embedded Coder® Support Package for ARM® Cortex-A® Processors to run a Simulink® model on an ARM Cortex-A9 (QEMU) emulator.
Ports
Output
Port_1 — UDP data received
numeric vector
UDP data received from remote host, returned as a numeric vector. Set the data type of this output by using the Data type for Message parameter.
Data Types: single
| double
| int8
| int16
| int32
| uint8
| uint16
| uint32
| Boolean
Parameters
Local IP port — IP Port on remote host
25000
(default) | integer from 1 to 65,535
Specify the local IP port number of the application on the hardware board on which you want to receive UDP packets. The port number must be an integer from 1 to 65,535.
Note
On Linux®, to set the local IP port number below 1024, run MATLAB® with root privileges. For example, at the Linux command line, enter:
sudo matlab
Programmatic Use
Block Parameter:
localPort
|
Remote IP address ('0.0.0.0' to accept all) — Remote IP address to listen
'0.0.0.0'
(default) | valid IP address
Specify the IP address from which the block accepts UDP packets. Entering a specific
IP address blocks, UDP packets from other addresses. To accept packets from all IP
addresses,use default value '0.0.0.0'
.
Programmatic Use
Block Parameter:
remoteURL
|
Receive buffer size (bytes) — Maximum number of data bytes in received data
8192
(default) | positive integer
Specify the size of the buffer size in which you want to store the received UDP packets. Specify the receive buffer size to be large enough to avoid data loss caused by buffer overflows.
Programmatic Use
Block Parameter:
recvBufferSize
|
Maximum length for Message — Maximum length of output UDP data
255
(default) | positive integer
Specify the maximum length of the output UDP data. This value must be greater than or equal to the data size of a UDP packet. The system truncates any data that exceeds this length.
Programmatic Use
Block Parameter:
dims
|
Data type for Message — Data type of output data
uint8
(default) | double
| single
| int8
| int16
| uint16
| int32
| uint32
| boolean
Select the data type of the output UDP data. This data type must be the same as the data type of UDP message sent by the remote host.
Programmatic Use
Block Parameter:
signalDataType
|
Output variable-size signal — Enable or disable variable output signal size
off
(default) | on
Select the Output variable-size signal if your model supports signals for varying length. In this case:
The output vector varies in length, depending on the amount of data in the UDP data received.
The block emits the data vector from a single unlabeled output.
Clear the Output variable-size signal if your model does not support signals of varying length. In this case:
The block emits a fixed-length output of 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 Data type for length parameter is enabled.
In both cases, the block truncates data that exceeds the Maximum length for Message.
Programmatic Use
Block Parameter:
isVarSize
|
Blocking time (seconds) — Time to wait for UDP packet
inf
(default) | nonnegative scalar
Specify the duration of wait time for a UDP packet at each sample before returning control to the scheduler.
Programmatic Use
Block Parameter:
blockingTime
|
Sample time (seconds) — Sample time
1
(default) | positive scalar
Specify how often the scheduler runs this block. Setting this parameter to a large value reduces the likelihood of dropped UDP messages.
Programmatic Use
Block Parameter:
sampletime
|
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2014b
See Also
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)