EtherCAT SubDevice
 
Loading...
Searching...
No Matches
Ethernet over EtherCAT

Description

Ethernet over EtherCAT (EoE) transparently tunnels standard Ethernet communication via EtherCAT. Tunneling allows the MainDevice to optimize Ethernet communication without affecting the process data communication. EoE enables communication with network devices. EoE is typically used for devices with TCP/IP stack, such as a web server, or for infrastructure devices such as switch ports, to which peripheral devices can be connected.

EoE Frame

EoE Header

EoE header
Name Size (Bit) Description
Type 4 0 = Frame Fragment Follows, 1 = Time Stamp Response Follows, 2 = IP Settings Request Follows, 3 = IP Settings Response Follows, 4 = MAC Filter Settings Request Follows, 5 = MAC Filter Settings Response Follows, 6-15 = Reserved
Port 4 Must be valid if LF=1. 0 = unspecified, 1 = Send/Received on Port 1, 2 = Send/Received on Port 2, 3..x = Send / Received on Port 3 .. x
LF 1 Last Fragment: Indicates the last fragment (Type=0 only)
TA 1 Time Stamp appended (only if LF=1)
TR 1 Time Stamp requested
Res 5
FragmentNo 6
Offset/CompleteSize 6 FragmentNo = 0: Contains needed buffer size, FragmentNo > 0: Offset of the fragment within the complete Ethernet Frame (Multiplied with 32)
FrameNo 4 Increments each new Ethernet Frame

EoE Frames

The EoE frame can contain different parts depending on the flags set in the header. The following diagram shows the possible combinations. Note that the fragment data is the same as the Ethernet frame, and it is always a multiple of 32 bits, except for the last fragment.

EoE frames

EoE API

The motivation of the code snippets is to provide a better understanding of how to configure and transport the Ethernet frames. For a detailed overview please refer to the Webserver Example.

Network settings

Register a function for network settings. The function is called when the EtherCAT MainDevice sends an EoE frame with the network device settings (IP address, Gateway, MAC address and DNS server). These parameters must be given then to the users virtual network interface.

static bool EC_SLV_APP_EoE_SS_settingIndHandler(
void *pContext,
uint16_t *pMac,
uint16_t *pIp,
uint16_t *pSubNet,
uint16_t *pDefaultGateway,
uint16_t *pDnsIp)
{
//TODO: Implement
return true;
}
EC_API_SLV_EoE_cbRegisterSettingIndHandler(handle, EC_SLV_APP_EoE_SS_settingIndHandler, pAppInstance);
uint32_t EC_API_SLV_EoE_cbRegisterSettingIndHandler(EC_API_SLV_SHandle_t *pHandle, EC_API_SLV_EoE_CBSettingIndHandler_t cbFunc, void *pContext)
This is the function to register EoE Setting Indication handler.
Definition ecSlvApi_EoE.c:89

Receiving a frame

This function registers a function which must be implemented by the user. The user defined function is called any time an EoE frame is received.

static bool EC_SLV_APP_EoE_SS_receiveHandler(void *pContext, uint16_t *pData, uint16_t size)
{
bool frameHandled = false;
uint32_t ret = 0;
//TODO: Implement
return frameHandled;
}
EC_API_SLV_EoE_cbRegisterReceiveHandler(handle, EC_SLV_APP_EoE_SS_receiveHandler, pAppInstance);
uint32_t EC_API_SLV_EoE_cbRegisterReceiveHandler(EC_API_SLV_SHandle_t *pHandle, EC_API_SLV_EoE_CBReceiveHandler_t cbFunc, void *pContext)
This is the function to register EoE receive handlers.
Definition ecSlvApi_EoE.c:50

Sending a frame

Use this function to send Ethernet frames over the EtherCAT network.

EC_API_SLV_EoE_sendFrame(handle, rxLength, aFrameBuf);
uint32_t EC_API_SLV_EoE_sendFrame(EC_API_SLV_SHandle_t *pHandle, uint16_t length, uint8_t *pData)
This is the function to send EoE frames.
Definition ecSlvApi_EoE.c:134

TwinCAT settings

MainDevice settings

Enable Virtual Ethernet Switch and the TCP/IP Stack connection for the EtherCAT MainDevice on TwinCAT. Adapt the parameters to your needs, but make sure your application can handle them.

MainDevice configuration

SubDevice settings

Enable Virtual Ethernet Port and set an IP address to the EtherCAT SubDevice. The default gateway must be the EtherCAT network interface IP address. These parameters will be given to the function registered to EC_API_SLV_EoE_cbRegisterReceiveHandler.

SubDevice configuration

Testing

For troubleshooting, it is highly recommended to use Wireshark. Some useful filters for this purpose are:

  • ecat_mailbox.eoe (EoE Fragment)
  • ecat_mailbox.eoe.fragment (EoE Fragment Header)
  • ecat_mailbox.eoe.fraghead (EoE Fragment Data)

For more filters please refer to the Wireshark EtherCAT Mailbox Filter Reference.