Headerfile for ethercatfoe.c. More...
#include <ethercattype.h>
Go to the source code of this file.
Classes | |
struct | eoe_ethaddr |
struct | eoe_ip4_addr |
struct | eoe_param |
struct | PACKED |
Macros | |
#define | EOE_DNS_NAME_LENGTH 32 |
#define | EOE_ETHADDR_LENGTH 6 |
#define | EOE_FRAG_DATA 0 |
#define | EOE_GET_ADDR_FILTER_REQ 8 |
#define | EOE_GET_ADDR_FILTER_RESP 9 |
#define | EOE_GET_IP_PARAM_REQ 6 |
#define | EOE_GET_IP_PARAM_RESP 7 |
#define | EOE_HDR_FRAG_NO (0x3F << 0) |
#define | EOE_HDR_FRAG_NO_GET(x) (((x) >> 0) & 0x3F) |
#define | EOE_HDR_FRAG_NO_OFFSET 0 |
#define | EOE_HDR_FRAG_NO_SET(x) (((x) & 0x3F) << 0) |
#define | EOE_HDR_FRAME_NO (0xF << 12) |
#define | EOE_HDR_FRAME_NO_GET(x) (((x) >> 12) & 0xF) |
#define | EOE_HDR_FRAME_NO_OFFSET 12 |
#define | EOE_HDR_FRAME_NO_SET(x) (((x) & 0xF) << 12) |
#define | EOE_HDR_FRAME_OFFSET (0x3F << 6) |
#define | EOE_HDR_FRAME_OFFSET_GET(x) (((x) >> 6) & 0x3F) |
#define | EOE_HDR_FRAME_OFFSET_OFFSET 6 |
#define | EOE_HDR_FRAME_OFFSET_SET(x) (((x) & 0x3F) << 6) |
#define | EOE_HDR_FRAME_PORT (0xF << 4) |
#define | EOE_HDR_FRAME_PORT_GET(x) (((x) >> 4) & 0xF) |
#define | EOE_HDR_FRAME_PORT_OFFSET 4 |
#define | EOE_HDR_FRAME_PORT_SET(x) (((x) & 0xF) << 4) |
#define | EOE_HDR_FRAME_TYPE (0xF << 0) |
#define | EOE_HDR_FRAME_TYPE_GET(x) (((x) >> 0) & 0xF) |
#define | EOE_HDR_FRAME_TYPE_OFFSET 0 |
#define | EOE_HDR_FRAME_TYPE_SET(x) (((x) & 0xF) << 0) |
#define | EOE_HDR_LAST_FRAGMENT (0x1 << 8) |
#define | EOE_HDR_LAST_FRAGMENT_GET(x) (((x) >> 8) & 0x1) |
#define | EOE_HDR_LAST_FRAGMENT_OFFSET 8 |
#define | EOE_HDR_LAST_FRAGMENT_SET(x) (((x) & 0x1) << 8) |
#define | EOE_HDR_TIME_APPEND (0x1 << 9) |
#define | EOE_HDR_TIME_APPEND_GET(x) (((x) >> 9) & 0x1) |
#define | EOE_HDR_TIME_APPEND_OFFSET 9 |
#define | EOE_HDR_TIME_APPEND_SET(x) (((x) & 0x1) << 9) |
#define | EOE_HDR_TIME_REQUEST (0x1 << 10) |
#define | EOE_HDR_TIME_REQUEST_GET(x) (((x) >> 10) & 0x1) |
#define | EOE_HDR_TIME_REQUEST_OFFSET 10 |
#define | EOE_HDR_TIME_REQUEST_SET(x) (((x) & 0x1) << 10) |
#define | EOE_HTONL(x) |
#define | EOE_HTONS(x) ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8)) |
#define | EOE_INIT_REQ 2 /* Spec SET IP REQ */ |
#define | EOE_INIT_RESP 3 /* Spec SET IP RESP */ |
#define | EOE_INIT_RESP_TIMESTAMP 1 |
#define | eoe_ip4_addr1(ipaddr) (((const uint8_t*)(&(ipaddr)->addr))[0]) |
#define | eoe_ip4_addr2(ipaddr) (((const uint8_t*)(&(ipaddr)->addr))[1]) |
#define | eoe_ip4_addr3(ipaddr) (((const uint8_t*)(&(ipaddr)->addr))[2]) |
#define | eoe_ip4_addr4(ipaddr) (((const uint8_t*)(&(ipaddr)->addr))[3]) |
#define | EOE_IP4_ADDR_TO_U32(ipaddr, a, b, c, d) (ipaddr)->addr = EOE_HTONL(EOE_MAKEU32(a,b,c,d)) |
#define | EOE_MAKEU32(a, b, c, d) |
#define | EOE_NTOHL(x) EOE_HTONL(x) |
#define | EOE_NTOHS(x) EOE_HTONS(x) |
#define | EOE_PARAM_DEFAULT_GATEWAY_INCLUDE (0x1 << 3) |
#define | EOE_PARAM_DNS_IP_INCLUDE (0x1 << 4) |
#define | EOE_PARAM_DNS_NAME_INCLUDE (0x1 << 5) |
#define | EOE_PARAM_IP_INCLUDE (0x1 << 1) |
#define | EOE_PARAM_MAC_INCLUDE (0x1 << 0) |
#define | EOE_PARAM_OFFSET 4 |
#define | EOE_PARAM_SUBNET_IP_INCLUDE (0x1 << 2) |
#define | EOE_RESULT_NO_DHCP_SUPPORT 0x0202 |
#define | EOE_RESULT_NO_FILTER_SUPPORT 0x0401 |
#define | EOE_RESULT_NO_IP_SUPPORT 0x0201 |
#define | EOE_RESULT_SUCCESS 0x0000 |
#define | EOE_RESULT_UNSPECIFIED_ERROR 0x0001 |
#define | EOE_RESULT_UNSUPPORTED_FRAME_TYPE 0x0002 |
#define | EOE_SET_ADDR_FILTER_REQ 4 |
#define | EOE_SET_ADDR_FILTER_RESP 5 |
Typedefs | |
typedef PACKED_BEGIN struct PACKED | ec_EOEt |
typedef PACKED_BEGIN struct PACKED eoe_ethaddr | eoe_ethaddr_t |
typedef struct eoe_ip4_addr | eoe_ip4_addr_t |
typedef PACKED_END struct eoe_param | eoe_param_t |
Functions | |
PACKED_END int | ecx_EOEdefinehook (ecx_contextt *context, void *hook) |
int | ecx_EOEgetIp (ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *ipparam, int timeout) |
int | ecx_EOEreadfragment (ec_mbxbuft *MbxIn, uint8 *rxfragmentno, uint16 *rxframesize, uint16 *rxframeoffset, uint16 *rxframeno, int *psize, void *p) |
int | ecx_EOErecv (ecx_contextt *context, uint16 slave, uint8 port, int *psize, void *p, int timeout) |
int | ecx_EOEsend (ecx_contextt *context, uint16 slave, uint8 port, int psize, void *p, int timeout) |
int | ecx_EOEsetIp (ecx_contextt *context, uint16 slave, uint8 port, eoe_param_t *ipparam, int timeout) |
Headerfile for ethercatfoe.c.
Definition in file ethercateoe.h.
#define EOE_DNS_NAME_LENGTH 32 |
DNS length according to ETG 1000.6
Definition at line 22 of file ethercateoe.h.
#define EOE_ETHADDR_LENGTH 6 |
Ethernet address length not including VLAN
Definition at line 24 of file ethercateoe.h.
#define EOE_FRAG_DATA 0 |
EoE frame types
Definition at line 103 of file ethercateoe.h.
#define EOE_GET_ADDR_FILTER_REQ 8 |
Definition at line 111 of file ethercateoe.h.
#define EOE_GET_ADDR_FILTER_RESP 9 |
Definition at line 112 of file ethercateoe.h.
#define EOE_GET_IP_PARAM_REQ 6 |
Definition at line 109 of file ethercateoe.h.
#define EOE_GET_IP_PARAM_RESP 7 |
Definition at line 110 of file ethercateoe.h.
#define EOE_HDR_FRAG_NO (0x3F << 0) |
Definition at line 81 of file ethercateoe.h.
#define EOE_HDR_FRAG_NO_GET | ( | x | ) | (((x) >> 0) & 0x3F) |
Definition at line 83 of file ethercateoe.h.
#define EOE_HDR_FRAG_NO_OFFSET 0 |
Header frame info 2
Definition at line 80 of file ethercateoe.h.
#define EOE_HDR_FRAG_NO_SET | ( | x | ) | (((x) & 0x3F) << 0) |
Definition at line 82 of file ethercateoe.h.
#define EOE_HDR_FRAME_NO (0xF << 12) |
Definition at line 89 of file ethercateoe.h.
#define EOE_HDR_FRAME_NO_GET | ( | x | ) | (((x) >> 12) & 0xF) |
Definition at line 91 of file ethercateoe.h.
#define EOE_HDR_FRAME_NO_OFFSET 12 |
Definition at line 88 of file ethercateoe.h.
#define EOE_HDR_FRAME_NO_SET | ( | x | ) | (((x) & 0xF) << 12) |
Definition at line 90 of file ethercateoe.h.
#define EOE_HDR_FRAME_OFFSET (0x3F << 6) |
Definition at line 85 of file ethercateoe.h.
#define EOE_HDR_FRAME_OFFSET_GET | ( | x | ) | (((x) >> 6) & 0x3F) |
Definition at line 87 of file ethercateoe.h.
#define EOE_HDR_FRAME_OFFSET_OFFSET 6 |
Definition at line 84 of file ethercateoe.h.
#define EOE_HDR_FRAME_OFFSET_SET | ( | x | ) | (((x) & 0x3F) << 6) |
Definition at line 86 of file ethercateoe.h.
#define EOE_HDR_FRAME_PORT (0xF << 4) |
Definition at line 63 of file ethercateoe.h.
#define EOE_HDR_FRAME_PORT_GET | ( | x | ) | (((x) >> 4) & 0xF) |
Definition at line 65 of file ethercateoe.h.
#define EOE_HDR_FRAME_PORT_OFFSET 4 |
Definition at line 62 of file ethercateoe.h.
#define EOE_HDR_FRAME_PORT_SET | ( | x | ) | (((x) & 0xF) << 4) |
Definition at line 64 of file ethercateoe.h.
#define EOE_HDR_FRAME_TYPE (0xF << 0) |
Definition at line 59 of file ethercateoe.h.
#define EOE_HDR_FRAME_TYPE_GET | ( | x | ) | (((x) >> 0) & 0xF) |
Definition at line 61 of file ethercateoe.h.
#define EOE_HDR_FRAME_TYPE_OFFSET 0 |
Header frame info 1
Definition at line 58 of file ethercateoe.h.
#define EOE_HDR_FRAME_TYPE_SET | ( | x | ) | (((x) & 0xF) << 0) |
Definition at line 60 of file ethercateoe.h.
#define EOE_HDR_LAST_FRAGMENT (0x1 << 8) |
Definition at line 67 of file ethercateoe.h.
#define EOE_HDR_LAST_FRAGMENT_GET | ( | x | ) | (((x) >> 8) & 0x1) |
Definition at line 69 of file ethercateoe.h.
#define EOE_HDR_LAST_FRAGMENT_OFFSET 8 |
Definition at line 66 of file ethercateoe.h.
#define EOE_HDR_LAST_FRAGMENT_SET | ( | x | ) | (((x) & 0x1) << 8) |
Definition at line 68 of file ethercateoe.h.
#define EOE_HDR_TIME_APPEND (0x1 << 9) |
Definition at line 71 of file ethercateoe.h.
#define EOE_HDR_TIME_APPEND_GET | ( | x | ) | (((x) >> 9) & 0x1) |
Definition at line 73 of file ethercateoe.h.
#define EOE_HDR_TIME_APPEND_OFFSET 9 |
Definition at line 70 of file ethercateoe.h.
#define EOE_HDR_TIME_APPEND_SET | ( | x | ) | (((x) & 0x1) << 9) |
Definition at line 72 of file ethercateoe.h.
#define EOE_HDR_TIME_REQUEST (0x1 << 10) |
Definition at line 75 of file ethercateoe.h.
#define EOE_HDR_TIME_REQUEST_GET | ( | x | ) | (((x) >> 10) & 0x1) |
Definition at line 77 of file ethercateoe.h.
#define EOE_HDR_TIME_REQUEST_OFFSET 10 |
Definition at line 74 of file ethercateoe.h.
#define EOE_HDR_TIME_REQUEST_SET | ( | x | ) | (((x) & 0x1) << 10) |
Definition at line 76 of file ethercateoe.h.
#define EOE_HTONL | ( | x | ) |
Definition at line 35 of file ethercateoe.h.
#define EOE_HTONS | ( | x | ) | ((((x) & 0x00ffUL) << 8) | (((x) & 0xff00UL) >> 8)) |
Definition at line 33 of file ethercateoe.h.
#define EOE_INIT_REQ 2 /* Spec SET IP REQ */ |
Definition at line 105 of file ethercateoe.h.
#define EOE_INIT_RESP 3 /* Spec SET IP RESP */ |
Definition at line 106 of file ethercateoe.h.
#define EOE_INIT_RESP_TIMESTAMP 1 |
Definition at line 104 of file ethercateoe.h.
#define eoe_ip4_addr1 | ( | ipaddr | ) | (((const uint8_t*)(&(ipaddr)->addr))[0]) |
Get one byte from the 4-byte address
Definition at line 48 of file ethercateoe.h.
#define eoe_ip4_addr2 | ( | ipaddr | ) | (((const uint8_t*)(&(ipaddr)->addr))[1]) |
Definition at line 49 of file ethercateoe.h.
#define eoe_ip4_addr3 | ( | ipaddr | ) | (((const uint8_t*)(&(ipaddr)->addr))[2]) |
Definition at line 50 of file ethercateoe.h.
#define eoe_ip4_addr4 | ( | ipaddr | ) | (((const uint8_t*)(&(ipaddr)->addr))[3]) |
Definition at line 51 of file ethercateoe.h.
#define EOE_IP4_ADDR_TO_U32 | ( | ipaddr, | |
a, | |||
b, | |||
c, | |||
d | |||
) | (ipaddr)->addr = EOE_HTONL(EOE_MAKEU32(a,b,c,d)) |
Set an IP address given by the four byte-parts
Definition at line 54 of file ethercateoe.h.
#define EOE_MAKEU32 | ( | a, | |
b, | |||
c, | |||
d | |||
) |
#define EOE_NTOHL | ( | x | ) | EOE_HTONL(x) |
Definition at line 39 of file ethercateoe.h.
#define EOE_NTOHS | ( | x | ) | EOE_HTONS(x) |
Definition at line 34 of file ethercateoe.h.
#define EOE_PARAM_DEFAULT_GATEWAY_INCLUDE (0x1 << 3) |
Definition at line 98 of file ethercateoe.h.
#define EOE_PARAM_DNS_IP_INCLUDE (0x1 << 4) |
Definition at line 99 of file ethercateoe.h.
#define EOE_PARAM_DNS_NAME_INCLUDE (0x1 << 5) |
Definition at line 100 of file ethercateoe.h.
#define EOE_PARAM_IP_INCLUDE (0x1 << 1) |
Definition at line 96 of file ethercateoe.h.
#define EOE_PARAM_MAC_INCLUDE (0x1 << 0) |
Definition at line 95 of file ethercateoe.h.
#define EOE_PARAM_OFFSET 4 |
EOE param
Definition at line 94 of file ethercateoe.h.
#define EOE_PARAM_SUBNET_IP_INCLUDE (0x1 << 2) |
Definition at line 97 of file ethercateoe.h.
#define EOE_RESULT_NO_DHCP_SUPPORT 0x0202 |
Definition at line 119 of file ethercateoe.h.
#define EOE_RESULT_NO_FILTER_SUPPORT 0x0401 |
Definition at line 120 of file ethercateoe.h.
#define EOE_RESULT_NO_IP_SUPPORT 0x0201 |
Definition at line 118 of file ethercateoe.h.
#define EOE_RESULT_SUCCESS 0x0000 |
EoE parameter result codes
Definition at line 115 of file ethercateoe.h.
#define EOE_RESULT_UNSPECIFIED_ERROR 0x0001 |
Definition at line 116 of file ethercateoe.h.
#define EOE_RESULT_UNSUPPORTED_FRAME_TYPE 0x0002 |
Definition at line 117 of file ethercateoe.h.
#define EOE_SET_ADDR_FILTER_REQ 4 |
Definition at line 107 of file ethercateoe.h.
#define EOE_SET_ADDR_FILTER_RESP 5 |
Definition at line 108 of file ethercateoe.h.
typedef PACKED_BEGIN struct PACKED ec_EOEt |
EOE structure. Used to interpret EoE mailbox packets.
typedef PACKED_BEGIN struct PACKED eoe_ethaddr eoe_ethaddr_t |
EOE ethernet address
typedef struct eoe_ip4_addr eoe_ip4_addr_t |
EOE ip4 address in network order
typedef PACKED_END struct eoe_param eoe_param_t |
EoE IP request structure, storage only, no need to pack
PACKED_END int ecx_EOEdefinehook | ( | ecx_contextt * | context, |
void * | hook | ||
) |
EoE fragment data handler hook. Should not block.
[in] | context | = context struct |
[in] | hook | = Pointer to hook function. |
Definition at line 52 of file ethercateoe.c.
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.
[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 |
Definition at line 181 of file ethercateoe.c.
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
[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 |
Definition at line 534 of file ethercateoe.c.
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.
[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 |
Definition at line 415 of file ethercateoe.c.
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.
[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 |
Definition at line 322 of file ethercateoe.c.
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.
[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 |
Definition at line 67 of file ethercateoe.c.