libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
pool.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 POOL_H
42#define POOL_H
43
44#include <libosal/queue.h>
45
46#include <libosal/types.h>
47#include <libosal/mutex.h>
48#include <libosal/semaphore.h>
49
50#include "libethercat/common.h"
51#include "libethercat/idx.h"
52
60#define LEC_MAX_POOL_DATA_SIZE (1600)
61
62// forward declaration
63struct ec;
64struct ec_datagram;
65
67typedef struct pool_entry {
68 void (*user_cb)(struct ec *pec, struct pool_entry *p_entry, struct ec_datagram *p_dg);
71
73
76
79
81typedef struct pool {
82 struct pool_queue avail;
83 osal_semaphore_t avail_cnt;
84 osal_mutex_t _pool_lock;
86
87#ifdef __cplusplus
88extern "C" {
89#endif
90
92
99int pool_open(pool_t *pp, osal_size_t cnt, pool_entry_t *entries);
100
102
108
110
119int pool_get(pool_t *pp, pool_entry_t **entry, osal_timer_t *timeout);
120
122
127
129
137int pool_peek(pool_t *pp, pool_entry_t **entry);
138
140
144void pool_put(pool_t *pp, pool_entry_t *entry);
145
147
152
153#ifdef __cplusplus
154}
155#endif
156
159#endif // POOL_H
160
ethercat master common stuff
TAILQ_HEAD(pool_queue, pool_entry)
queue head for pool queue
void pool_put_head(pool_t *pp, pool_entry_t *entry)
Put entry back to pool in front.
int pool_get(pool_t *pp, pool_entry_t **entry, osal_timer_t *timeout)
Get a datagram from pool.
#define LEC_MAX_POOL_DATA_SIZE
Maximum data size of ony pool entry.
Definition pool.h:60
void pool_put(pool_t *pp, pool_entry_t *entry)
Put entry back to pool.
int pool_peek(pool_t *pp, pool_entry_t **entry)
Peek next entry from pool.
int pool_open(pool_t *pp, osal_size_t cnt, pool_entry_t *entries)
Create a new data pool.
int pool_close(pool_t *pp)
Destroys a datagram pool.
struct pool_entry pool_entry_t
Pool queue entry.
struct pool pool_t
the datagram pool itself
void pool_remove(pool_t *pp, pool_entry_t *entry)
Remove entry from pool.
ethercat index
Definition datagram.h:74
ethercat master structure
Definition ec.h:188
index entry
Definition idx.h:54
Pool queue entry.
Definition pool.h:67
osal_uint8_t data[LEC_MAX_POOL_DATA_SIZE]
Data entry.
Definition pool.h:74
idx_entry_t * p_idx
Assigned datagram index.
Definition pool.h:70
void(* user_cb)(struct ec *pec, struct pool_entry *p_entry, struct ec_datagram *p_dg)
User callback.
Definition pool.h:68
TAILQ_ENTRY(pool_entry) qh
Queue handle of pool objects.
int user_arg
User argument for user_cb.
Definition pool.h:69
the datagram pool itself
Definition pool.h:81
osal_mutex_t _pool_lock
Pool lock.
Definition pool.h:84
osal_semaphore_t avail_cnt
Available datagrams in pool.
Definition pool.h:83
struct pool_queue avail
Queue with available datagrams.
Definition pool.h:82