comms.h
Go to the documentation of this file.
1 
35 #ifndef UM6_COMMS_H
36 #define UM6_COMMS_H
37 
38 #include <stdint.h>
39 #include <string>
40 
41 namespace serial
42 {
43 class Serial;
44 }
45 
46 namespace um6
47 {
48 
49 class SerialTimeout : public std::exception {};
50 
51 class BadChecksum : public std::exception {};
52 
53 class Registers;
54 class Accessor_;
55 
56 class Comms
57 {
58 public:
59  explicit Comms(serial::Serial* s) : serial_(s), first_spin_(true)
60  {
61  }
62 
69  int16_t receive(Registers* r);
70 
71  void send(const Accessor_& a) const;
72 
73  bool sendWaitAck(const Accessor_& a);
74 
75  static const uint8_t PACKET_HAS_DATA;
76  static const uint8_t PACKET_IS_BATCH;
77  static const uint8_t PACKET_BATCH_LENGTH_MASK;
78  static const uint8_t PACKET_BATCH_LENGTH_OFFSET;
79 
80  static std::string checksum(const std::string& s);
81 
82  static std::string message(uint8_t address, std::string data);
83 
84 private:
87 };
88 } // namespace um6
89 
90 #endif // UM6_COMMS_H
91 
static const uint8_t PACKET_HAS_DATA
Definition: comms.h:75
serial::Serial * serial_
Definition: comms.h:86
static const uint8_t PACKET_IS_BATCH
Definition: comms.h:76
Definition: comms.h:46
static const uint8_t PACKET_BATCH_LENGTH_OFFSET
Definition: comms.h:78
Comms(serial::Serial *s)
Definition: comms.h:59
static const uint8_t PACKET_BATCH_LENGTH_MASK
Definition: comms.h:77
bool first_spin_
Definition: comms.h:85


um6
Author(s): Mike Purvis
autogenerated on Thu Sep 26 2019 03:18:02