UDP in - Ethernet UDP input mailbox

This page is based on SDK 2025.2.

The UDP input mailbox block allows receiving up to 1024 bytes of data via Ethernet using the UDP protocol (in SDK versions prior to 2025.2, the size limit is 8 byte). To send data, the UDP output mailbox should be used.

The block returns the data received via UDP on a specified port, formatted as a vector. The Signal decoding format parameter defines the data type of each element, and the Number of signals parameter defines the length of the output vector. The data can be interpreted as one of the following types: int8, int16, int32, uint8, uint16, uint32, float32, or float64.

Example: if Signal decoding format is set to uint32 (4 bytes) and Number of signals is 100, then:

  • Size of the UDP data = 4 × 100 = 400 bytes
  • Output = vector of 100 uint32 elements

Simulink block

Signal specification

  • The first signal returns the data received via UDP, formatted as a vector. The Signal decoding format parameter defines the data type of each element, and the Number of signals parameter defines the length of the output vector.
  • The second signal is the data valid output. It is set to 1 each time new data are available.

Parameters

  • Ethernet port number: sets the port number on which data will be received.
  • Signal decoding format: defines the type of the data output (int8, int16, int32, uint8, uint16, uint32, float32, or float64).
  • Number of signals: specifies the vector size of the data output signal.
  • Byte order: defines the byte order in which the data will be read. (Little-endian or Big-endian)
  • Initial value: sets the initial value of the data output before any data are received.
Ethernet input mailbox Simulink dialog parameters

PLECS block

  • The first signal returns the data received via UDP, formatted as a vector. The Signal decoding format parameter defines the data type of each element, and the Number of signals parameter defines the length of the output vector.
  • The second signal is the data valid output. It is set to 1 each time new data are available.

Parameters

  • Ethernet port number: sets the port number on which data will be received.
  • Signal decoding format: defines the type of the data output (int8, int16, int32, uint8, uint16, uint32, float32, or float64).
  • Number of signals: specifies the vector size of the data output signal.
  • Byte order: defines the byte order in which the data will be read. (Little-endian or Big-endian)
  • Initial value: sets the initial value of the data output before any data are received.
Ethernet input mailbox Plecs dialog parameters

C++ functions

bool Eth_ConfigureInputMailbox(unsigned int mailboxId, unsigned int port, tEndianness endianness = LITTLE_ENDIAN, size_t msgLength = 4);Code language: C++ (cpp)

Routine used to configure an Ethernet UDP input Mailbox. It has to be called in UserInit().

bool Eth_ConfigureInputMailboxInitialValue(unsigned int mailbox_id, void* data, size_t size);Code language: C++ (cpp)
void Eth_ConfigureInputMailboxInitialValue(unsigned int mailboxId, unsigned int initialValue);Code language: C++ (cpp)
void Eth_ConfigureInputMailboxInitialValue(unsigned int mailboxId, int initialValue);Code language: C++ (cpp)
void Eth_ConfigureInputMailboxInitialValue(unsigned int mailboxId, float initialValue);Code language: C++ (cpp)

Routines used to set the initial value read for an Input mailbox. These functions can be used to configure the initial value returned by the Eth_Read functions before any UDP message is received. They have to be called in UserInit().

int Eth_Read(unsigned int mailboxId, void* data, size_t size);Code language: C++ (cpp)
int Eth_Read(unsigned int mailboxId, unsigned int &data);Code language: C++ (cpp)
int Eth_Read(unsigned int mailboxId, int &data);Code language: C++ (cpp)
int Eth_Read(unsigned int mailboxId, float &data);Code language: C++ (cpp)

These functions are used to receive data on Ethernet using UDP. They have to be called during the control interrupt.