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:
47  EthercatCom() { }
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);
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_;
90  EtherCAT_Frame *frame_;
91  int handle_;
92  unsigned line_;
93 };
94 
95 
96 #endif /* ETHERCAT_COM_H */
EthercatCom
Definition: ethercat_com.h:44
EthercatOobCom::txandrx
bool txandrx(struct EtherCAT_Frame *frame)
Definition: ethercat_com.cpp:182
EthercatOobCom::EthercatOobCom
EthercatOobCom(struct netif *ni)
Definition: ethercat_com.cpp:64
EthercatCom::txandrx
virtual bool txandrx(struct EtherCAT_Frame *frame)=0
EthercatDirectCom
Definition: ethercat_com.h:57
EthercatCom::EthercatCom
EthercatCom()
Definition: ethercat_com.h:79
EthercatDirectCom::txandrx
bool txandrx(struct EtherCAT_Frame *frame)
Definition: ethercat_com.cpp:59
EthercatDirectCom::EthercatDirectCom
EthercatDirectCom(EtherCAT_DataLinkLayer *dll)
Definition: ethercat_com.cpp:39
EthercatOobCom::READY_TO_SEND
@ READY_TO_SEND
Definition: ethercat_com.h:89
EthercatDirectCom::~EthercatDirectCom
~EthercatDirectCom()
Definition: ethercat_com.cpp:45
EthercatOobCom::lock
bool lock(unsigned line)
Definition: ethercat_com.cpp:107
EthercatOobCom::share_cond_
pthread_cond_t share_cond_
Definition: ethercat_com.h:87
EthercatOobCom::busy_cond_
pthread_cond_t busy_cond_
Definition: ethercat_com.h:88
EthercatOobCom::state_
enum EthercatOobCom::@1 state_
EthercatOobCom::line_
unsigned line_
Definition: ethercat_com.h:92
EthercatDirectCom::dll_
EtherCAT_DataLinkLayer * dll_
Definition: ethercat_com.h:67
EthercatDirectCom::txandrx_once
bool txandrx_once(struct EtherCAT_Frame *frame)
Definition: ethercat_com.cpp:50
EthercatOobCom::~EthercatOobCom
~EthercatOobCom()
Definition: ethercat_com.cpp:101
EthercatOobCom::trylock
bool trylock(unsigned line)
Definition: ethercat_com.cpp:118
EthercatOobCom::tx
void tx()
Definition: ethercat_com.cpp:194
EthercatOobCom::mutex_
pthread_mutex_t mutex_
Definition: ethercat_com.h:86
EthercatOobCom::ni_
struct netif * ni_
Definition: ethercat_com.h:85
EthercatOobCom
Definition: ethercat_com.h:70
EthercatOobCom::frame_
EtherCAT_Frame * frame_
Definition: ethercat_com.h:90
EthercatCom::txandrx_once
virtual bool txandrx_once(struct EtherCAT_Frame *frame)=0
EthercatOobCom::IDLE
@ IDLE
Definition: ethercat_com.h:89
EthercatCom::~EthercatCom
virtual ~EthercatCom()
Definition: ethercat_com.h:85
EthercatOobCom::WAITING_TO_RECV
@ WAITING_TO_RECV
Definition: ethercat_com.h:89
EthercatOobCom::handle_
int handle_
Definition: ethercat_com.h:91
EthercatOobCom::unlock
bool unlock(unsigned line)
Definition: ethercat_com.cpp:132
EthercatOobCom::txandrx_once
bool txandrx_once(struct EtherCAT_Frame *frame)
Definition: ethercat_com.cpp:146


ethercat_hardware
Author(s): Rob Wheeler , Derek King
autogenerated on Thu Sep 26 2024 02:44:04