CARMA C++
JanzDio.h
Go to the documentation of this file.
1 
10 #ifndef CARMA_CANBUS_JANZDIO_H
11 #define CARMA_CANBUS_JANZDIO_H
12 
13 #include "carma/canbus/Dio.h"
14 
15 #include <boost/thread/mutex.hpp>
16 #include <string>
17 #include <vector>
18 
19 namespace carma {
20 namespace canbus {
21 
32  class JanzDio : public carma::canbus::Dio {
33  public:
34 
43  JanzDio( );
44 
57  JanzDio( const std::string & dev,
58  bool resetOnStart = false );
59 
73  JanzDio( const std::string & dev0,
74  const std::string & dev1,
75  bool resetOnStart = false );
76 
86  JanzDio( const ::std::vector< ::std::string > & devs,
87  bool resetOnStart = false );
88 
92  ~JanzDio();
93 
98  void powerOn();
99 
104  void powerOff();
105 
110  void resetHi();
111 
116  void resetLo();
117 
122  void reservedHi();
123 
128  void reservedLo();
129 
134  void clear();
135 
136  private:
137 
138  struct DeviceInfo {
139  int fd; // File descriptor.
140  std::string name; // Name of ttl device.
141  unsigned char state; // Bit state.
142  };
143 
144  // Common initialization
145  void initializeDevice( const std::string & deviceName,
146  int flags,
147  bool resetOnStart );
148  // Emulation hook.
149  void mttlWrite(int fd, int data);
150 
151  // Twiddle bits.
152  void set( int bit );
153  void unset( int bit );
154 
155  // Member data
156  std::vector< DeviceInfo > devs_; // List of our janz devices
157  const bool emulate_; // Emulate Janz Dio card?
158  boost::mutex mutex_; // Coarse lock
159 
160  }; // End class JanzDio
161 }} // namespace carma::canbus
162 #endif // CARMA_CANBUS_JANZDIO_H
void powerOn()
Assert the &#39;power&#39; line.
void clear()
Clear (unassert) all lines.
Dio abstract base class.
Definition: Dio.h:19
~JanzDio()
Destructor.
void resetHi()
Assert the reset line.
void resetLo()
Unassert the &#39;reset&#39; line.
void powerOff()
Unassert the &#39;power&#39; line.
void reservedLo()
Unassert the &#39;reserved&#39; line.
Dio class for use with Janz char driver.
Definition: JanzDio.h:32
JanzDio()
Default constructor for hardware emulation.
Declaration of carma::canbus::Dio class.
void reservedHi()
Assert the &#39;reserved&#39; line.