Robotics Library  0.7.0
Comedi.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2009, Markus Rickert
3 // All rights reserved.
4 //
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 //
8 // * Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 // POSSIBILITY OF SUCH DAMAGE.
25 //
26 
27 #ifndef RL_HAL_COMEDI_H
28 #define RL_HAL_COMEDI_H
29 
30 #include <comedilib.h>
31 #include <string>
32 
33 #include "Com.h"
34 
35 namespace rl
36 {
37  namespace hal
38  {
39  class Comedi : public Com
40  {
41  public:
42  Comedi(const ::std::string& filename = "/dev/comedi0");
43 
44  virtual ~Comedi();
45 
46  void close();
47 
48  unsigned int getAref() const;
49 
50  ::std::string getBoardName() const;
51 
52  comedi_t* getDevice() const;
53 
54  ::std::string getDriverName() const;
55 
56  int getFileno() const;
57 
58  lsampl_t getMax(const ::std::size_t& subdevice, const ::std::size_t& channel) const;
59 
60  ::std::size_t getNumChannels(const ::std::size_t& subdevice) const;
61 
62  ::std::size_t getNumRanges(const ::std::size_t& subdevice, const ::std::size_t& channel) const;
63 
64  ::std::size_t getNumSubdevices() const;
65 
66  unsigned int getRange() const;
67 
68  ::std::size_t getSubdeviceFlags(const ::std::size_t& subdevice) const;
69 
70  void open();
71 
72  void read(const ::std::size_t& subdevice, const ::std::size_t& channel, double& data);
73 
74  void read(const ::std::size_t& subdevice, const ::std::size_t& channel, float& data);
75 
76  void setAref(const unsigned int& aref);
77 
78  void setRange(const unsigned int& range);
79 
80  void write(const ::std::size_t& subdevice, const ::std::size_t& channel, const double& data);
81 
82  void write(const ::std::size_t& subdevice, const ::std::size_t& channel, const float& data);
83 
84  protected:
85 
86  private:
87  unsigned int aref;
88 
89  comedi_t* device;
90 
91  ::std::string filename;
92 
93  unsigned int range;
94  };
95  }
96 }
97 
98 #endif // RL_HAL_COMEDI_H
rl::hal::Comedi::getFileno
int getFileno() const
Definition: Comedi.cpp:101
rl::hal::Comedi::range
unsigned int range
Definition: Comedi.h:93
rl::hal::Comedi::getRange
unsigned int getRange() const
Definition: Comedi.cpp:159
rl::hal::Comedi::getDevice
comedi_t * getDevice() const
Definition: Comedi.cpp:82
Com.h
rl::hal::Comedi::getBoardName
::std::string getBoardName() const
Definition: Comedi.cpp:69
rl::hal::Comedi::getDriverName
::std::string getDriverName() const
Definition: Comedi.cpp:88
rl::hal::Comedi::getNumChannels
::std::size_t getNumChannels(const ::std::size_t &subdevice) const
Definition: Comedi.cpp:127
rl::hal::Comedi::Comedi
Comedi(const ::std::string &filename="/dev/comedi0")
Definition: Comedi.cpp:34
rl::hal::Comedi::close
void close()
Definition: Comedi.cpp:52
rl::hal::Comedi::getSubdeviceFlags
::std::size_t getSubdeviceFlags(const ::std::size_t &subdevice) const
Definition: Comedi.cpp:165
rl::hal::Comedi::getNumSubdevices
::std::size_t getNumSubdevices() const
Definition: Comedi.cpp:153
rl::hal::Comedi::open
void open()
Definition: Comedi.cpp:178
rl::hal::Comedi
Definition: Comedi.h:40
rl::hal::Comedi::setRange
void setRange(const unsigned int &range)
Definition: Comedi.cpp:251
rl::hal::Comedi::device
comedi_t * device
Definition: Comedi.h:89
rl::hal::Comedi::getMax
lsampl_t getMax(const ::std::size_t &subdevice, const ::std::size_t &channel) const
Definition: Comedi.cpp:114
rl::hal::Comedi::aref
unsigned int aref
Definition: Comedi.h:87
rl::hal::Comedi::getNumRanges
::std::size_t getNumRanges(const ::std::size_t &subdevice, const ::std::size_t &channel) const
Definition: Comedi.cpp:140
rl::hal::Comedi::write
void write(const ::std::size_t &subdevice, const ::std::size_t &channel, const double &data)
Definition: Comedi.cpp:257
rl::hal::Com
Definition: Com.h:35
rl::hal::Comedi::~Comedi
virtual ~Comedi()
Definition: Comedi.cpp:43
rl::hal::Comedi::filename
::std::string filename
Definition: Comedi.h:91
rl::hal::Comedi::setAref
void setAref(const unsigned int &aref)
Definition: Comedi.cpp:245
rl::hal::Comedi::getAref
unsigned int getAref() const
Definition: Comedi.cpp:63
rl::hal::Comedi::read
void read(const ::std::size_t &subdevice, const ::std::size_t &channel, double &data)
Definition: Comedi.cpp:191
rl
Robotics Library.
Definition: AnalogInput.cpp:30