ETH in - Ethernet input mailbox

The Ethernet 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 was 32-bit). To send up to 1024 bytes of data via Ethernet using the UDP/IP protocol, the Ethernet output mailbox should be used.

The ETH input block reads n bytes of data received via UDP/IP on the specified port and applies it to the output port of the block. The value of n is defined by the Signal decoding format parameter (in bytes) multiplied by the Number of signals parameter. The data can be interpreted as one of the following types: int8, int16, int32, uint8, uint16, uint32, float32, or float64. It features a second output that indicates that new data has been received. The value on the output data port will remain unchanged until new data are received.

Simulink block

Signal specification

  • The data output signal returns n bytes of data received via UDP, formatted as a vector. The value of n is defined by the Signal decoding format parameter (in bytes) multiplied by the Number of signals parameter. The output data type is configured by the Signal decoding format parameter, and the vector length is defined by the Number of signals parameter. (e.g. with Signal coding format set to uint32 and Number of signals set to 100,  the data size read will be 4 x 100 = 400 bytes. The output vector will have a length of 100, with each element occupying 4 bytes)
  • 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. The value is interpreted as a uint64.
Ethernet input mailbox Simulink dialog parameters

PLECS block

Signal specification

  • The data output signal returns 32 bits of data received via UDP. The output data type is configured by Signal decoding format parameter.
  • The second signal is the data valid output. It is set to 1 each time new data are available.
Ethernet input mailbox block PLECS

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. The value is interpreted as a uint64.
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 send data on Ethernet using UDP. They have to be called during the control interrupt.