SOEM  v1.4.0
Functions
ethercateoe.c File Reference

Ethernet over EtherCAT (EoE) module. More...

#include <stdio.h>
#include <string.h>
#include "osal.h"
#include "oshw.h"
#include "ethercat.h"

Functions

static void EOE_ip_uint32_to_byte (eoe_ip4_addr_t *ip, uint8_t *byte_ip)
 
static void EOE_ip_byte_to_uint32 (uint8_t *byte_ip, eoe_ip4_addr_t *ip)
 
int ecx_EOEdefinehook (ecx_contextt *context, void *hook)
 
int ecx_EOEsetIp (ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *ipparam, int timeout)
 
int ecx_EOEgetIp (ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *ipparam, int timeout)
 
int ecx_EOEsend (ecx_contextt *context, uint16 slave, uint8 port, int psize, void *p, int timeout)
 
int ecx_EOErecv (ecx_contextt *context, uint16 slave, uint8 port, int *psize, void *p, int timeout)
 
int ecx_EOEreadfragment (ec_mbxbuft *MbxIn, uint8 *rxfragmentno, uint16 *rxframesize, uint16 *rxframeoffset, uint16 *rxframeno, int *psize, void *p)
 

Detailed Description

Ethernet over EtherCAT (EoE) module.

Set / Get IP functions Blocking send/receive Ethernet Frame Read incoming EoE fragment to Ethernet Frame

Function Documentation

◆ ecx_EOEdefinehook()

int ecx_EOEdefinehook ( ecx_contextt *  context,
void *  hook 
)

EoE fragment data handler hook. Should not block.

Parameters
[in]context= context struct
[in]hook= Pointer to hook function.
Returns
1

◆ ecx_EOEgetIp()

int ecx_EOEgetIp ( ecx_contextt *  context,
uint16  slave,
uint8  port,
eoe_param_t ipparam,
int  timeout 
)

EoE EOE get IP, blocking. Waits for response from the slave.

Parameters
[in]context= Context struct
[in]slave= Slave number
[in]port= Port number on slave if applicable
[out]ipparam= IP parameter data retrived from slave
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response or returned result code

◆ ecx_EOEreadfragment()

int ecx_EOEreadfragment ( ec_mbxbuft MbxIn,
uint8 *  rxfragmentno,
uint16 *  rxframesize,
uint16 *  rxframeoffset,
uint16 *  rxframeno,
int *  psize,
void *  p 
)

EoE mailbox fragment read

Will take the data in incoming mailbox buffer and copy to destination Ethernet frame buffer at given offset and update current fragment variables

Parameters
[in]MbxIn= Received mailbox containing fragment data
[in,out]rxfragmentno= Fragment number
[in,out]rxframesize= Frame size
[in,out]rxframeoffset= Frame offset
[in,out]rxframeno= Frame number
[in,out]psize= Size in bytes of frame buffer.
[out]p= Pointer to frame buffer
Returns
0= if fragment OK, >0 if last fragment, <0 on error

◆ ecx_EOErecv()

int ecx_EOErecv ( ecx_contextt *  context,
uint16  slave,
uint8  port,
int *  psize,
void *  p,
int  timeout 
)

EoE ethernet buffer read, blocking.

If the buffer is larger than the mailbox size then the buffer is received by several fragments. The function will assamble the fragments into a complete Ethernet buffer.

Parameters
[in]context= context struct
[in]slave= Slave number
[in]port= Port number on slave if applicable
[in,out]psize= Size in bytes of parameter buffer.
[in]p= Pointer to parameter buffer
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response or error code

◆ ecx_EOEsend()

int ecx_EOEsend ( ecx_contextt *  context,
uint16  slave,
uint8  port,
int  psize,
void *  p,
int  timeout 
)

EoE ethernet buffer write, blocking.

If the buffer is larger than the mailbox size then the buffer is sent in several fragments. The function will split the buf data in fragments and send them to the slave one by one.

Parameters
[in]context= context struct
[in]slave= Slave number
[in]port= Port number on slave if applicable
[in]psize= Size in bytes of parameter buffer.
[in]p= Pointer to parameter buffer
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave transmission

◆ ecx_EOEsetIp()

int ecx_EOEsetIp ( ecx_contextt *  context,
uint16  slave,
uint8  port,
eoe_param_t ipparam,
int  timeout 
)

EoE EOE set IP, blocking. Waits for response from the slave.

Parameters
[in]context= Context struct
[in]slave= Slave number
[in]port= Port number on slave if applicable
[in]ipparam= IP parameter data to be sent
[in]timeout= Timeout in us, standard is EC_TIMEOUTRXM
Returns
Workcounter from last slave response or returned result code

◆ EOE_ip_byte_to_uint32()

static void EOE_ip_byte_to_uint32 ( uint8_t *  byte_ip,
eoe_ip4_addr_t ip 
)
static

EoE utility function to convert eoe ip bytes to uint32.

Parameters
[in]byte_ip= eoe ip 4th octet, 3ed octet, 2nd octet, 1st octet
[out]ip= ip in uint32

◆ EOE_ip_uint32_to_byte()

static void EOE_ip_uint32_to_byte ( eoe_ip4_addr_t ip,
uint8_t *  byte_ip 
)
static

EoE utility function to convert uint32 to eoe ip bytes.

Parameters
[in]ip= ip in uint32
[out]byte_ip= eoe ip 4th octet, 3ed octet, 2nd octet, 1st octet