mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Refactor for a central include directory
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
#ifndef __PACKETIZER_H_
|
||||
#define __PACKETIZER_H_
|
||||
|
||||
#include "icsneo/communication/packet.h"
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class Packetizer {
|
||||
public:
|
||||
static uint8_t ICSChecksum(const std::vector<uint8_t>& data);
|
||||
std::vector<uint8_t>& packetWrap(std::vector<uint8_t>& data, bool shortFormat);
|
||||
|
||||
bool input(const std::vector<uint8_t>& bytes);
|
||||
std::vector<std::shared_ptr<Packet>> output();
|
||||
|
||||
bool disableChecksum = false; // Even for short packets
|
||||
bool align16bit = true; // Not needed for Gigalog, Galaxy, etc and newer
|
||||
|
||||
private:
|
||||
enum class ReadState {
|
||||
SearchForHeader,
|
||||
ParseHeader,
|
||||
ParseLongStylePacketHeader,
|
||||
GetData
|
||||
};
|
||||
ReadState state = ReadState::SearchForHeader;
|
||||
|
||||
int currentIndex = 0;
|
||||
int packetLength = 0;
|
||||
int headerSize = 0;
|
||||
bool checksum = false;
|
||||
bool gotGoodPackets = false; // Tracks whether we've ever gotten a good packet
|
||||
Packet packet;
|
||||
std::deque<uint8_t> bytes;
|
||||
|
||||
std::vector<std::shared_ptr<Packet>> processedPackets;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user