rmp_io.h
Go to the documentation of this file.
1 
39 #ifndef RMP_IO_H
40 #define RMP_IO_H
41 
42 #include <vector>
43 #include <cstdio>
44 
45 #include <boost/thread.hpp>
46 
47 #include <segwayrmp/segwayrmp.h>
48 
49 namespace segwayrmp {
50 
55 struct Packet {
56  unsigned short id;
57  unsigned char channel;
58  unsigned char data[8];
60  Packet() : id(0), channel(0) {
61  for (int i = 0; i < 8; ++i) { data[i] = 0x00; }
62  }
63 };
64 
68 class RMPIO {
69 public:
70  RMPIO() : canceled(false) {}
74  virtual void connect() = 0;
75 
79  virtual void disconnect() = 0;
80 
88  virtual int read(unsigned char* buffer, int size) = 0;
89 
97  virtual int write(unsigned char* buffer, int size) = 0;
98 
104  void getPacket(Packet &packet);
105 
111  void sendPacket(Packet &packet);
112 
118  bool isConnected() {return this->connected;}
119 
123  void cancel() {this->canceled = true;}
124 
125 protected:
126  void fillBuffer();
127  unsigned char computeChecksum(unsigned char* usb_packet);
128 
129  bool connected;
130  bool canceled;
131 
132  std::vector<unsigned char> data_buffer;
133 };
134 
135 DEFINE_EXCEPTION(PacketRetrievalException, "Error retrieving a packet from the"
136  " SegwayRMP: ", "Unspecified");
137 
138 } // Namespace segwayrmp
139 
140 #endif
void cancel()
Definition: rmp_io.h:123
DEFINE_EXCEPTION(PacketRetrievalException,"Error retrieving a packet from the"" SegwayRMP: ","Unspecified")
bool connected
Definition: rmp_io.h:129
std::vector< unsigned char > data_buffer
Definition: rmp_io.h:132
unsigned char channel
Definition: rmp_io.h:57
bool isConnected()
Definition: rmp_io.h:118
unsigned short id
Definition: rmp_io.h:56
unsigned char data[8]
Definition: rmp_io.h:58


libsegwayrmp
Author(s): William Woodall
autogenerated on Mon Jun 10 2019 13:46:49