#ifndef __PACKETIZER_H_ #define __PACKETIZER_H_ #include "communication/include/packet.h" #include #include #include namespace icsneo { class Packetizer { public: static uint8_t ICSChecksum(const std::vector& data); std::vector& packetWrap(std::vector& data); bool input(const std::vector& bytes); std::vector> 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 bytes; std::vector> processedPackets; }; } #endif