libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
eoe.h
Go to the documentation of this file.
1
13/*
14 * This file is part of libethercat.
15 *
16 * libethercat is free software; you can redistribute it and/or
17 * modify it under the terms of the GNU Lesser General Public
18 * License as published by the Free Software Foundation; either
19 * version 3 of the License, or (at your option) any later version.
20 *
21 * libethercat is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 * Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public
27 * License along with libethercat (LICENSE.LGPL-V3); if not, write
28 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
29 * Floor, Boston, MA 02110-1301, USA.
30 *
31 * Please note that the use of the EtherCAT technology, the EtherCAT
32 * brand name and the EtherCAT logo is only permitted if the property
33 * rights of Beckhoff Automation GmbH are observed. For further
34 * information please contact Beckhoff Automation GmbH & Co. KG,
35 * Hülshorstweg 20, D-33415 Verl, Germany (www.beckhoff.com) or the
36 * EtherCAT Technology Group, Ostendstraße 196, D-90482 Nuremberg,
37 * Germany (ETG, www.ethercat.org).
38 *
39 */
40
41#ifndef LIBETHERCAT_EOE_H
42#define LIBETHERCAT_EOE_H
43
44#include <libosal/types.h>
45#include <libosal/mutex.h>
46#include <libosal/semaphore.h>
47
48#include "libethercat/common.h"
49
57#define LEC_EOE_MAC_LEN (6u)
58#define LEC_EOE_IP_ADDRESS_LEN (4u)
59#define LEC_EOE_SUBNET_LEN (4u)
60#define LEC_EOE_GATEWAY_LEN (4u)
61#define LEC_EOE_DNS_LEN (4u)
62#define LEC_EOE_DNS_NAME_LEN (128u)
63
64typedef struct ec_eoe_slave_config {
65 int use_eoe;
66
67 osal_uint8_t mac[LEC_EOE_MAC_LEN];
68 osal_uint8_t ip_address[LEC_EOE_IP_ADDRESS_LEN];
69 osal_uint8_t subnet[LEC_EOE_SUBNET_LEN];
70 osal_uint8_t gateway[LEC_EOE_GATEWAY_LEN];
71 osal_uint8_t dns[LEC_EOE_DNS_LEN];
72 osal_char_t dns_name[LEC_EOE_DNS_NAME_LEN];
74
75typedef struct ec_eoe {
77 pool_t response_pool;
78
82
83 osal_mutex_t lock;
84 osal_semaphore_t send_sync;
85} ec_eoe_t;
86
87#ifdef __cplusplus
88extern "C" {
89#endif
90
92
99void ec_eoe_init(ec_t *pec, osal_uint16_t slave);
100
102
109void ec_eoe_deinit(ec_t *pec, osal_uint16_t slave);
110
112
121void ec_eoe_enqueue(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry);
122
124
142int ec_eoe_set_ip_parameter(ec_t *pec, osal_uint16_t slave, osal_uint8_t *mac,
143 osal_uint8_t *ip_address, osal_uint8_t *subnet, osal_uint8_t *gateway,
144 osal_uint8_t *dns, osal_char_t *dns_name);
145
146// send ethernet frame, fragmented if needed
160int ec_eoe_send_frame(ec_t *pec, osal_uint16_t slave, osal_uint8_t *frame,
161 osal_size_t frame_len);
162
163// setup tun interface
172
173// Destroy tun interface
179
180#ifdef __cplusplus
181}
182#endif
183
184#endif // LIBETHERCAT_EOE_H
185
ethercat master common stuff
osal_uint8_t subnet[LEC_EOE_SUBNET_LEN]
Subnet to configure (optional, maybe NULL).
Definition eoe.h:69
int ec_eoe_setup_tun(ec_t *pec)
osal_uint8_t ip_address[LEC_EOE_IP_ADDRESS_LEN]
IP address to configure (optional, maybe NULL).
Definition eoe.h:68
pool_t recv_pool
Mailbox message with EoE fragments received.
Definition eoe.h:76
osal_uint8_t mac[LEC_EOE_MAC_LEN]
MAC address to configure (mandatory)
Definition eoe.h:67
void ec_eoe_destroy_tun(ec_t *pec)
osal_uint8_t dns[LEC_EOE_DNS_LEN]
DNS to configure (optional, maybe NULL).
Definition eoe.h:71
osal_uint8_t gateway[LEC_EOE_GATEWAY_LEN]
Gateway to configure (optional, maybe NULL).
Definition eoe.h:70
void ec_eoe_init(ec_t *pec, osal_uint16_t slave)
initialize EoE structure
int ec_eoe_send_frame(ec_t *pec, osal_uint16_t slave, osal_uint8_t *frame, osal_size_t frame_len)
pool_entry_t free_frames[128]
Static Ethernet frames for Pool, do not use directly.
Definition eoe.h:79
pool_t eth_frames_recv_pool
Pool where to store Ethernet frames nobody cared so far.
Definition eoe.h:81
pool_t eth_frames_free_pool
Pool with Ethernet frames currently unused.
Definition eoe.h:80
void ec_eoe_enqueue(ec_t *pec, osal_uint16_t slave, pool_entry_t *p_entry)
Enqueue EoE message received from slave.
int ec_eoe_set_ip_parameter(ec_t *pec, osal_uint16_t slave, osal_uint8_t *mac, osal_uint8_t *ip_address, osal_uint8_t *subnet, osal_uint8_t *gateway, osal_uint8_t *dns, osal_char_t *dns_name)
Set IP parameters to slave with EoE support.
int use_eoe
Using EoE on actual slave.
Definition eoe.h:65
void ec_eoe_deinit(ec_t *pec, osal_uint16_t slave)
deinitialize EoE structure
osal_char_t dns_name[LEC_EOE_DNS_NAME_LEN]
DNS name to configure (optional, maybe NULL).
Definition eoe.h:72
Definition eoe.h:64
Definition eoe.h:75
ethercat master structure
Definition ec.h:192
Pool queue entry.
Definition pool.h:67
the datagram pool itself
Definition pool.h:84