Hekateros  3.4.3
RoadNarrows Robotics Robot Arm Project
hekSysBoard.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Hekateros
4 //
5 // Library: libhekateros
6 //
7 // File: hekSysBoard.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2014-09-18 16:53:49 -0600 (Thu, 18 Sep 2014) $
12  * $Rev: 3748 $
13  *
14  * \brief \h_hek original system board.
15  *
16  * \note The original system board is deprecated. However a newer version may
17  * be resurected at a future time, so keep the code.
18  *
19  * \author Robin Knight (robin.knight@roadnarrows.com)
20  * \author Daniel Packard (daniel@roadnarrows.com)
21  *
22  * \copyright
23  * \h_copy 2013-2017. RoadNarrows LLC.\n
24  * http://www.roadnarrows.com\n
25  * All Rights Reserved
26  */
27 /*
28  * @EulaBegin@
29  *
30  * Unless otherwise stated explicitly, all materials contained are copyrighted
31  * and may not be used without RoadNarrows LLC's written consent,
32  * except as provided in these terms and conditions or in the copyright
33  * notice (documents and software) or other proprietary notice provided with
34  * the relevant materials.
35  *
36  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
37  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
38  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
39  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
40  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
41  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42  *
43  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
44  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
45  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
46  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
47  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
48  *
49  * @EulaEnd@
50  */
51 ////////////////////////////////////////////////////////////////////////////////
52 
53 #ifndef _HEK_SYS_BOARD_H
54 #define _HEK_SYS_BOARD_H
55 
56 #include <string>
57 
58 #include "rnr/rnrconfig.h"
59 #include "rnr/log.h"
60 #include "rnr/i2c.h"
61 
62 #include "Hekateros/hekateros.h"
63 #include "Hekateros/hekOptical.h"
64 
65 namespace hekateros
66 {
68  {
69  public:
70 
71  /*!
72  * \brief Default constructor.
73  */
75  {
76  m_i2c.fd = -1;
77  m_i2c.addr = 0;
78  }
79 
80  /*!
81  * \brief Destructor.
82  */
83  virtual ~HekSysBoard()
84  {
85  close();
86  }
87 
88  /*!
89  * \brief Open all interfaces monitoring hardware.
90  *
91  * \param dev \h_i2c device.
92  *
93  * \copydoc doc_return_std
94  */
95  virtual int open(const std::string& dev=HekI2CDevice);
96 
97  /*!
98  * \brief Close all interfaces to monitoring hardware.
99  *
100  * \copydoc doc_return_std
101  */
102  virtual int close();
103 
104  /*!
105  * \brief Scan and initialize hardware.
106  *
107  * \copydoc doc_return_std
108  */
109  virtual int scan();
110 
111  /*!
112  * \brief Command to read firmware version.
113  *
114  * param [out] ver Version number.
115  *
116  * \copydoc doc_return_std
117  */
118  virtual int cmdReadFwVersion(int &ver);
119 
120  /*!
121  * \brief Command to read limit bit state.
122  *
123  * \return Returns limit switches state as a bit packed byte.
124  */
125  virtual byte_t cmdReadLimits();
126 
127  /*!
128  * \brief Command to read auxilliary bit state.
129  *
130  * Auxillary bits are usually End Effector GPIO, but allows room for
131  * additional bits.
132  *
133  * \return Returns auxilliary switches state as a bit packed byte.
134  */
135  virtual byte_t cmdReadAux();
136 
137  /*!
138  * \brief Command to read one I/O pin.
139  *
140  * \param id Pin identifier.
141  *
142  * \return Return pin state 0 or 1.
143  */
144  virtual int cmdReadPin(int id);
145 
146  /*!
147  * \brief Command to write value to an I/O pin.
148  *
149  * \param id Pin identifier.
150  * \param val Pin state 0 or 1.
151  *
152  * \copydoc doc_return_std
153  */
154  virtual int cmdWritePin(int id, int val);
155 
156  /*!
157  * \brief Command to configure direction of an I/O pin.
158  *
159  * \param id Pin identifier.
160  * \param dir Pin direction 'i' or 'o'.
161  *
162  * \copydoc doc_return_std
163  */
164  virtual int cmdConfigPin(int id, char dir);
165 
166  /*!
167  * \brief Command to set Alarm LED.
168  *
169  * \param val LED 0==off or 1==on value.
170  *
171  * \copydoc doc_return_std
172  */
173  virtual int cmdSetAlarmLED(int val);
174 
175  /*!
176  * \brief Command to set Status LED.
177  *
178  * \param val LED 0==off or 1==on value.
179  *
180  * \copydoc doc_return_std
181  */
182  virtual int cmdSetStatusLED(int val);
183 
184  /*!
185  * \brief Command to set monitoring state to halting.
186  *
187  * \copydoc doc_return_std
188  */
189  virtual int cmdSetHaltingState();
190 
191  protected:
192  i2c_struct m_i2c; ///< i2c bus
193 
194  /*!
195  * \brief Read I/O expander byte.
196  *
197  * \param byCmd I/O expander command.
198  *
199  * \return Byte value.
200  */
201  byte_t readIOExp(byte_t byCmd);
202 
203  /*!
204  * \brief Read I/O expander port 0.
205  *
206  * All optical limit switches are tied to port 0.
207  *
208  * \return Port 0 byte value.
209  */
210  byte_t readIOExpPort0()
211  {
213  }
214 
215  /*!
216  * \brief Read I/O expander port 1.
217  *
218  * All end effector i/o are tied to port 1.
219  *
220  * \return Port 1 byte value.
221  */
222  byte_t readIOExpPort1()
223  {
225  }
226 
227  /*!
228  * \brief Write byte to I/O expander.
229  *
230  * \param byCmd I/O expander command.
231  * \param Byte value.
232  *
233  * \copydoc doc_return_std
234  */
235  int writeIOExp(byte_t byCmd, byte_t byVal);
236  };
237 
238 } // namespace hekateros
239 
240 
241 #endif // _HEK_SYS_BOARD_H
virtual int close()
Close all interfaces to monitoring hardware.
byte_t readIOExpPort1()
Read I/O expander port 1.
Definition: hekSysBoard.h:222
<b><i>Hekateros</i></b> optical limit switches.
byte_t readIOExpPort0()
Read I/O expander port 0.
Definition: hekSysBoard.h:210
virtual int cmdWritePin(int id, int val)
Command to write value to an I/O pin.
virtual int cmdSetAlarmLED(int val)
Command to set Alarm LED.
const char *const HekI2CDevice
i2c device name
Definition: hekateros.h:382
virtual byte_t cmdReadLimits()
Command to read limit bit state.
virtual ~HekSysBoard()
Destructor.
Definition: hekSysBoard.h:83
virtual int scan()
Scan and initialize hardware.
virtual byte_t cmdReadAux()
Command to read auxilliary bit state.
virtual int cmdReadFwVersion(int &ver)
Command to read firmware version.
virtual int cmdSetStatusLED(int val)
Command to set Status LED.
static const byte_t HekIOExpCmdInput0
read port 0 command
Definition: hekOptical.h:72
Top-level package include file.
HekSysBoard()
Default constructor.
Definition: hekSysBoard.h:74
static const byte_t HekIOExpCmdInput1
read port 1 command
Definition: hekOptical.h:73
virtual int open(const std::string &dev=HekI2CDevice)
Open all interfaces monitoring hardware.
Definition: hekSysBoard.cxx:72
byte_t readIOExp(byte_t byCmd)
Read I/O expander byte.
int writeIOExp(byte_t byCmd, byte_t byVal)
Write byte to I/O expander.
virtual int cmdConfigPin(int id, char dir)
Command to configure direction of an I/O pin.
virtual int cmdReadPin(int id)
Command to read one I/O pin.
The <b><i>Hekateros</i></b> namespace encapsulates all <b><i>Hekateros</i></b> related constructs...
Definition: hekateros.h:56
i2c_struct m_i2c
i2c bus
Definition: hekSysBoard.h:192
virtual int cmdSetHaltingState()
Command to set monitoring state to halting.