libethercat - an embeddable realtime EtherCAT-master library
Communicate with EtherCAT slaves attached to a Network interface.
Loading...
Searching...
No Matches
async_loop.h
1
12/*
13 * This file is part of libethercat.
14 *
15 * libethercat is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU Lesser General Public
17 * License as published by the Free Software Foundation; either
18 * version 3 of the License, or (at your option) any later version.
19 *
20 * libethercat is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 * Lesser General Public License for more details.
24 *
25 * You should have received a copy of the GNU Lesser General Public
26 * License along with libethercat (LICENSE.LGPL-V3); if not, write
27 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
28 * Floor, Boston, MA 02110-1301, USA.
29 *
30 * Please note that the use of the EtherCAT technology, the EtherCAT
31 * brand name and the EtherCAT logo is only permitted if the property
32 * rights of Beckhoff Automation GmbH are observed. For further
33 * information please contact Beckhoff Automation GmbH & Co. KG,
34 * Hülshorstweg 20, D-33415 Verl, Germany (www.beckhoff.com) or the
35 * EtherCAT Technology Group, Ostendstraße 196, D-90482 Nuremberg,
36 * Germany (ETG, www.ethercat.org).
37 *
38 */
39
40#ifndef LIBETHERCAT_MESSAGE_POOL_H
41#define LIBETHERCAT_MESSAGE_POOL_H
42
43#include <libosal/queue.h>
44
45#include <libosal/types.h>
46#include <libosal/mutex.h>
47#include <libosal/semaphore.h>
48
49#include "libethercat/common.h"
50
51struct ec;
52
54typedef enum ec_async_message_id {
55 EC_MSG_CHECK_GROUP,
56 EC_MSG_CHECK_SLAVE,
57 EC_MSG_CHECK_ALL
58} ec_async_message_id_t;
59
60typedef osal_uint32_t ec_async_message_payload_t;
61
63typedef struct ec_message {
64 ec_async_message_id_t id;
65 ec_async_message_payload_t payload;
68
76
77TAILQ_HEAD(ec_message_pool_queue, ec_message_entry);
78typedef struct ec_message_pool_queue ec_message_pool_queue_t;
79
80typedef struct ec_message_pool {
81 ec_message_pool_queue_t queue;
82 osal_semaphore_t avail_cnt;
83 osal_mutex_t lock;
85
86#define EC_ASYNC_MESSAGE_LOOP_COUNT 100
87typedef struct ec_async_loop {
88 ec_message_entry_t entries[EC_ASYNC_MESSAGE_LOOP_COUNT];
89
92
94 osal_task_t loop_tid;
95 struct ec *pec;
96
97 osal_timer_t next_check_group;
99
100#ifdef __cplusplus
101extern "C" {
102#endif
103
105
112int ec_async_loop_create(ec_async_loop_t *paml, struct ec *pec);
113
115
121int ec_async_loop_destroy(ec_async_loop_t *paml);
122
124
128void ec_async_check_group(ec_async_loop_t *paml, osal_uint16_t gid);
129
131
134void ec_async_check_all(ec_async_loop_t *paml);
135
136#ifdef __cplusplus
137}
138#endif
139
140#endif // LIBETHERCAT_ASYNC_MESSAGE_LOOP_H
141
ethercat master common stuff
Definition async_loop.h:87
struct ec * pec
ethercat master pointer
Definition async_loop.h:95
ec_message_pool_t avail
empty messages
Definition async_loop.h:90
osal_task_t loop_tid
loop thread id
Definition async_loop.h:94
int loop_running
loop thread run flag
Definition async_loop.h:93
ec_message_pool_t exec
execute messages
Definition async_loop.h:91
Message queue qentry.
Definition async_loop.h:70
ec_message_t msg
message itself
Definition async_loop.h:74
TAILQ_ENTRY(ec_message_entry) qh
handle to message entry queue
Definition async_loop.h:80
ec_message_pool_queue_t queue
message pool queue
Definition async_loop.h:81
osal_mutex_t lock
pool lock
Definition async_loop.h:83
osal_semaphore_t avail_cnt
available messages in pool queue
Definition async_loop.h:82
Message for asynchronous loop.
Definition async_loop.h:63
ec_async_message_payload_t payload
payload
Definition async_loop.h:65
ec_async_message_id_t id
index
Definition async_loop.h:64
ethercat master structure
Definition ec.h:188