F2838x-M4 UDP Receive
Receive UDP packets from UDP host
C2000™ Microcontroller Blockset / / F2838x / M4
The UDP Receive block receives UDP packets from a UDP host. Use the block for stateless and connectionless data exchange.
With each sample, the block outputs the contents of a UDP packet as a data vector of the size specified in the Data size (N) parameter.
The block receives the packets on the port number specified in the Local IP Port parameter from the IP address specified in the Remote IP address (0.0.0.0 for accepting all) parameter.
You can choose to receive the UDP packets in the blocking or nonblocking mode.
Your antivirus software or firewall might block UDP traffic. Configure the software to allow traffic from a specific IP port number.
Due to RAM memory limitations on the F2838x(ARM Cortex-M4), loading application to RAM is not supported for this block.
CPU Timer 2 of F2838x Arm Cortex-M core (Connectivity Manager) provides time base to lwIP stack. It is configured to trigger an interrupt every 1 ms. This timer should not be re-configured if Ethernet blocks are being used in the model. If the corresponding interrupt is armed through Hardware Interrupt block, it will run the interrupt handler every 1 ms.
Data — UDP packets received from sending UDP host
At each sample time, the port outputs the contents of a packet received as a data vector of the size specified in the Data size (N) parameter.
Status — Determine if requested data is received at the given time step
The port outputs
0 (success) when the received number of data
elements is less than or equal to Data size (N) specified in
the block. Otherwise, it outputs a nonzero value, indicating that no new data is
Local IP Port — IP port on the receiving UDP host
25000 (default) | positive integer in the range
Specify the port number of the application from which you want to receive the packets. Match the local port number with the remote port number of the sending host.
Remote IP address (0.0.0.0 for accepting all) — IP address from which the block receives UDP packets
18.104.22.168 (default) |
Specify the IP address of the remote host from which the block receives packets.
To receive packets from all the sending hosts, specify
Data type — Data type of elements in UDP packets
uint8 (default) |
Select the data type of the elements in the UDP packets received by the block. The size of each element depends on its data type.
Data size (N) — Number of data elements in each UDP packet
Specify the number of elements that you want to receive in each packet.
Ensure the following conditions are considered when data is sent to UDP Receive in the target to avoid data loss.
The UDP block can handle the maximum packet size (datagram size) of
1472bytes. Ensure the packet size sent to the target is less than or equal to
Ensure the size of the data sent to the target is less than or equal the packet size (datagram size).
Wait until data received — Wait until requested data is available
on (default) | off
on— When you select this parameter, the read operation runs in the blocking mode. The read operation is blocked when the block is waiting for the requested data. If data is available, the block outputs the data. If data is not available, the block waits for the data.
A task overrun occurs if the target hardware is still waiting for the data when the next read operation begins.
To fix overruns, increase the time step by using the Sample time parameter.
off— When you clear this parameter, the read operation runs in the nonblocking mode. When reading data, if data is not available, the block contains the packet received in the previous time step. In this mode, the block does not wait for the requested data to be available.
Sample time — How often this block reads packets from the sending UDP host
Specify how often the block should read the port buffer. Enter a value greater
-1 (for inherited sample time).
This value defaults to a sample time of
0.1 seconds. Smaller
values require the processor to complete the same number of instructions in less time,
and this can cause task overruns.
Introduced in R2020b