ethercat_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015, Jonathan Meyer
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice,
7  * this list of conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution.
11  * * Neither the names of Tokyo Opensource Robotics Kyokai Association. nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 // copied from https://github.com/ros-industrial/robotiq/blob/jade-devel/robotiq_ethercat/src/ethercat_manager.cpp
29 
30 #ifndef ETHERCAT_MANAGER_H
31 #define ETHERCAT_MANAGER_H
32 
33 #include <stdexcept>
34 #include <string>
35 
36 #include <stdint.h>
37 
38 #include <boost/scoped_array.hpp>
39 #include <boost/thread.hpp>
40 #include <boost/thread/mutex.hpp>
41 
42 namespace ethercat {
43 
48 class EtherCatError : public std::runtime_error
49 {
50 public:
51  explicit EtherCatError(const std::string& what)
52  : std::runtime_error(what)
53  {}
54 };
55 
66 {
67 public:
77  EtherCatManager(const std::string& ifname);
78 
79  ~EtherCatManager();
80 
91  void write(int slave_no, uint8_t channel, uint8_t value);
92 
99  uint8_t readInput(int slave_no, uint8_t channel) const;
100 
107  uint8_t readOutput(int slave_no, uint8_t channel) const;
108 
117  template <typename T>
118  uint8_t writeSDO(int slave_no, uint16_t index, uint8_t subidx, T value) const;
119 
127  template <typename T>
128  T readSDO(int slave_no, uint16_t index, uint8_t subidx) const;
129 
133  int getNumClinets() const;
134 
138  void getStatus(int slave_no, std::string &name, int &eep_man, int &eep_id, int &eep_rev, int &obits, int &ibits, int &state, int &pdelay, int &hasdc, int &activeports, int &configadr) const;
139 
140 private:
141  bool initSoem(const std::string& ifname);
142 
143  const std::string ifname_;
144  uint8_t iomap_[4096];
146  boost::thread cycle_thread_;
147  mutable boost::mutex iomap_mutex_;
149 };
150 
151 }
152 
153 #endif
154 
EtherCatError(const std::string &what)
unsigned short uint16_t
unsigned char uint8_t
This class provides a CPP interface to the SimpleOpenEthercatMaster library Given the name of an ethe...
EtherCAT exception. Currently this is only thrown in the event of a failure to construct an EtherCat ...


ethercat_manager
Author(s): Jonathan Meyer
autogenerated on Mon Jun 10 2019 14:02:24