ethercat_com.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #ifndef ETHERCAT_COM_H
36 #define ETHERCAT_COM_H
37 
38 #include <al/ethercat_AL.h>
39 #include <al/ethercat_master.h>
40 #include <al/ethercat_slave_handler.h>
41 #include <dll/ethercat_dll.h>
42 #include <pthread.h>
43 
45 {
46 protected:
48 
49 public:
50  virtual bool txandrx(struct EtherCAT_Frame * frame)=0;
51  virtual bool txandrx_once(struct EtherCAT_Frame * frame)=0;
52 
53  virtual ~EthercatCom() { }
54 };
55 
56 
58 {
59 public:
60  EthercatDirectCom(EtherCAT_DataLinkLayer *dll);
62 
63  bool txandrx(struct EtherCAT_Frame * frame);
64  bool txandrx_once(struct EtherCAT_Frame * frame);
65 
66 protected:
67  EtherCAT_DataLinkLayer *dll_;
68 };
69 
70 class EthercatOobCom : public EthercatCom
71 {
72 public:
73  EthercatOobCom(struct netif *ni);
74  ~EthercatOobCom();
75 
76  bool txandrx(struct EtherCAT_Frame * frame);
77  bool txandrx_once(struct EtherCAT_Frame * frame);
78 
79  void tx();
80 protected:
81  bool lock(unsigned line);
82  bool trylock(unsigned line);
83  bool unlock(unsigned line);
84 
85  struct netif *ni_;
86  pthread_mutex_t mutex_;
87  pthread_cond_t share_cond_;
88  pthread_cond_t busy_cond_;
89  enum {IDLE=0, READY_TO_SEND=1, WAITING_TO_RECV=2} state_;
90  EtherCAT_Frame *frame_;
91  int handle_;
92  unsigned line_;
93 };
94 
95 
96 #endif /* ETHERCAT_COM_H */
unsigned line_
Definition: ethercat_com.h:92
struct netif * ni_
Definition: ethercat_com.h:85
EtherCAT_DataLinkLayer * dll_
Definition: ethercat_com.h:67
pthread_mutex_t mutex_
Definition: ethercat_com.h:86
virtual bool txandrx_once(struct EtherCAT_Frame *frame)=0
pthread_cond_t busy_cond_
Definition: ethercat_com.h:88
virtual ~EthercatCom()
Definition: ethercat_com.h:53
pthread_cond_t share_cond_
Definition: ethercat_com.h:87
EtherCAT_Frame * frame_
Definition: ethercat_com.h:90
virtual bool txandrx(struct EtherCAT_Frame *frame)=0


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Mar 4 2021 03:10:21