General description

The ETH input block allows receiving 32-bit values via Ethernet using the UDP protocol.

It reads 4 bytes of data (32-bit) received via UDP/IP on the specified port and applies it to the output port of the block. The data can be interpreted as an int32, an uint32, or a float. The ETH input mailbox block features a second output that indicates that a 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 32 bits of data received via UDP. The output data type is configured by the Signal decoding format parameter.

  • 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 to the data output (int32, uint32, or float32).

  • 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.

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.

Parameters

  • Ethernet port number: sets the port number on which data will be received.

  • Signal decoding format: defines the type of to the data output (int32, uint32, or float32).

  • 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.

C++ functions

Configure input mailbox
bool Eth_ConfigureInputMailbox(unsigned int mailboxId, unsigned int port,
    tEndianness endianness = LITTLE_ENDIAN);

Configures an Ethernet UDP/IP input mailbox.

It has to be called in the UserInit()code.

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: UDP port number. Data received on this port are stored in the mailbox and can be read using the Eth_Read() function.

  • endianness: defines the bytes order (BIG_ENDIAN or LITTLE_ENDIAN).

Return value

  • bool: returns false if too many output mailboxes were created or if port was already assigned to another mailbox.

Configure input mailbox initial value
void Eth_ConfigureInputMailboxInitialValue(unsigned int mailboxId,
    unsigned int initialValue);
void Eth_ConfigureInputMailboxInitialValue(unsigned int mailboxId,
    int initialValue);
void Eth_ConfigureInputMailboxInitialValue(unsigned int mailboxId,
    float initialValue);

These functions can be used to configure the initial value return by the Eth_Read functions before any UDP message is received.

They have 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.
  • initialValue: default data which will be returned by Eth_Read() before data are received in the mailbox.

Read
int Eth_Read(unsigned int mailboxId, unsigned int &data);
int Eth_Read(unsigned int mailboxId, int &data);
int Eth_Read(unsigned int mailboxId, float &data);

These functions are used to read data received in the input mailbox. The data read will remain unchanged until new data are received.

They have to be called during the control interrupt.

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.
  • data: data read from the input mailbox. Several data types and prototypes are available.

Return value

  • int: returns 1 if new data is available since the last read. Returns 0 otherwise. 

  • No labels