ETH out - Ethernet output mailbox

The Ethernet output mailbox block allows sending 32-bit values via Ethernet using the UDP/IP protocol.

It supports two operating modes:

  • On-demand mode: the user manually triggers the message transmissions.
  • Periodical mode: the message is sent periodically, whether the data has been changed or not. The user can configure the transmission frequency.

Simulink block

Signal specification

  • The first input is the data to send. The accepted data type is specified by the Signal coding format parameter.
  • The second input is the send data signal. It is used to initiate a data transmission when the on-demand mode has been selected. Data is sent upon a rising edge on this signal.

Parameters

  • Ethernet port number: sets the destination port to which the data will be sent.
  • Ethernet IP address : selects the IP address to whom the data will be sent.
  • Signal coding format : defines the data type accepted in the data input (int32, uint32, or float32).
  • Byte order : defines the byte order in which the data will be sent. (little-endian or big-endian)
  • Tx frequency : sets the data transmission frequency if the periodical mode has been selected.

PLECS block

Signal specification

  • The first input is the data to send. The accepted data type is specified by the Signal coding format parameter.
  • The second input is the send data signal. It is used to initiate a data transmission when the on-demand mode has been selected. Data is sent upon a rising edge on this signal.

Parameters

  • Ethernet port number: sets the destination port to which the data will be sent.
  • Ethernet IP address: selects the IP address to whom the data will be sent.
  • Signal coding format: defines the data type accepted in the data input (int32, uint32 or float32).
  • Byte order: defines the byte order in which the data will be sent. (little-endian or big-endian)
  • Tx frequency: sets the data transmission frequency if the periodical mode has been selected.

C++ functions

bool Eth_ConfigureOutputMailbox(unsigned int mailboxId, unsigned int port, const char* ipAddress, float maxTxFrequency = 100, tEndianness endianness = LITTLE_ENDIAN);Code language: C++ (cpp)

Configures an Ethernet UDP output mailbox.

It has to be called in UserInit().

Parameters

  • mailboxId: a unique ID used to distinguish mailboxes from each other. This ID must be unique throughout the code for all ETH and CAN input/output mailboxes.
  • port: sets the destination port to which the data will be sent.
  • ipAddress: sets the destination IP address to whom the data will be sent.
  • maxTxFrequency: maximal frequency at which data can be sent. The frequency must be a multiple of the interrupt frequency. If the requested frequency is not achievable, it will be automatically set to the closest valid frequency.
  • endianness: defines the frame bytes order. (BIG_ENDIAN or LITTLE_ENDIAN)

Return value

  • bool: returns false if too many output mailboxes were created or if the port was already assigned to another ETH output mailbox.
int Eth_Write(unsigned int mailboxId, unsigned int data);Code language: C++ (cpp)
int Eth_Write(unsigned int mailboxId, int data);Code language: C++ (cpp)
int Eth_Write(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.

Parameters

  • maildboxId: a unique ID used to distinguish mailboxes from each other. This ID must be unique throughout the code for all ETH and CAN input/output mailboxes.
  • data: data which will be sent. Several data types and prototypes are available.

Return value

  • int: returns 1 if the data has been loaded in the write buffer. Returns 0 otherwise.