-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBasicPacketProcessor.h
More file actions
58 lines (44 loc) · 1.28 KB
/
BasicPacketProcessor.h
File metadata and controls
58 lines (44 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
* BasicPacket.h
*
* Created on: Jul 30, 2021
* Author: dmounday
*/
#ifndef BASICPACKETPROCESSOR_H_
#define BASICPACKETPROCESSOR_H_
#include <cstdint>
#include <vector>
#include <string>
namespace pentair_control {
enum class PacketState {
UNDEFINED,
PENTAIR_INCOMPLETE, // Intelliflow
PENTAIR_COMPLETE, // packet is comlete
SWG_INCOMPLETE,
SWG_COMPLETE, // IC40 uses unique packet preemble
};
const uint8_t DLE {0x10};
const uint8_t STX {0x02};
const uint8_t ETX {0x03};
class BasicPacketProcessor {
public:
BasicPacketProcessor ();
virtual ~BasicPacketProcessor ();
virtual PacketState CapturePacket(uint8_t b) = 0;
virtual uint8_t MsgID()const =0;
virtual const std::vector<uint8_t>& MsgData()const = 0;
/**
* @brief Return std::string in JSON format of packet data.
*
* @return std::string: JSON packet data.
*/
virtual std::string PacketJSON()=0;
inline long ChkSumErrors(){return ckSumErrors_;}
inline long TotalPackets(){return totalPackets_;}
inline long BadData(){return badData_;}
long totalPackets_; // Total Packets received.
long ckSumErrors_; // Count of packets failing check sum.
long badData_; // corrupt packets.
};
} /* namespace pentair_control */
#endif /* BASICPACKETPROCESSOR_H_ */