comms.h
Go to the documentation of this file.
00001 
00035 #ifndef UM6_COMMS_H
00036 #define UM6_COMMS_H
00037 
00038 #include <stdint.h>
00039 #include <string>
00040 
00041 namespace serial
00042 {
00043 class Serial;
00044 }
00045 
00046 namespace um6
00047 {
00048 
00049 class SerialTimeout : public std::exception {};
00050 
00051 class BadChecksum : public std::exception {};
00052 
00053 class Registers;
00054 class Accessor_;
00055 
00056 class Comms
00057 {
00058 public:
00059   explicit Comms(serial::Serial* s) : serial_(s), first_spin_(true)
00060   {
00061   }
00062 
00069   int16_t receive(Registers* r);
00070 
00071   void send(const Accessor_& a) const;
00072 
00073   bool sendWaitAck(const Accessor_& a);
00074 
00075   static const uint8_t PACKET_HAS_DATA;
00076   static const uint8_t PACKET_IS_BATCH;
00077   static const uint8_t PACKET_BATCH_LENGTH_MASK;
00078   static const uint8_t PACKET_BATCH_LENGTH_OFFSET;
00079 
00080   static std::string checksum(const std::string& s);
00081 
00082   static std::string message(uint8_t address, std::string data);
00083 
00084 private:
00085   bool first_spin_;
00086   serial::Serial* serial_;
00087 };
00088 }  // namespace um6
00089 
00090 #endif  // UM6_COMMS_H
00091 


um6
Author(s): Mike Purvis
autogenerated on Thu Jun 6 2019 19:02:20