comms.h
Go to the documentation of this file.
1 
35 #ifndef UM7_COMMS_H_
36 #define UM7_COMMS_H_
37 
38 #include <stdint.h>
39 #include <string>
40 
41 namespace serial
42 {
43 class Serial;
44 }
45 
46 namespace um7
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 um7
89 
90 #endif // UM7_COMMS_H
91 
serial::Serial * serial_
Definition: comms.h:86
bool first_spin_
Definition: comms.h:85
Comms(serial::Serial *s)
Definition: comms.h:59
static const uint8_t PACKET_BATCH_LENGTH_MASK
Definition: comms.h:77
Definition: comms.h:46
static const uint8_t PACKET_IS_BATCH
Definition: comms.h:76
static const uint8_t PACKET_BATCH_LENGTH_OFFSET
Definition: comms.h:78
static const uint8_t PACKET_HAS_DATA
Definition: comms.h:75


um7
Author(s): Mike Purvis , Alex Brown
autogenerated on Tue Feb 11 2020 03:26:50