Communication::Packet refactored out to Packet

This commit is contained in:
Paul Hollinsky
2018-09-25 17:40:33 -04:00
parent d27b516894
commit 585abe7cbb
6 changed files with 70 additions and 47 deletions
+1 -6
View File
@@ -4,7 +4,7 @@
#include "communication/include/icommunication.h"
#include "communication/include/command.h"
#include "communication/include/network.h"
#include "communication/include/messagecallback.h"
#include "communication/include/packet.h"
#include <memory>
#include <vector>
#include <atomic>
@@ -40,11 +40,6 @@ public:
void setAlign16Bit(bool enable) { align16bit = enable; }
class Packet {
public:
Network network;
std::vector<uint8_t> data;
};
protected:
std::shared_ptr<ICommunication> impl;
+3 -2
View File
@@ -1,9 +1,9 @@
#ifndef __MESSAGEDECODER_H_
#define __MESSAGEDECODER_H_
#include "communication/include/communication.h"
#include "communication/message/include/message.h"
#include "communication/message/include/canmessage.h"
#include "communication/include/packet.h"
#include "communication/include/network.h"
#include <queue>
#include <vector>
@@ -16,7 +16,8 @@ namespace icsneo {
class MessageDecoder {
public:
std::shared_ptr<Message> decodePacket(const std::shared_ptr<Communication::Packet>& message);
static uint64_t GetUInt64FromLEBytes(uint8_t* bytes);
std::shared_ptr<Message> decodePacket(const std::shared_ptr<Packet>& message);
private:
typedef uint16_t icscm_bitfield;
+18
View File
@@ -0,0 +1,18 @@
#ifndef __PACKET_H_
#define __PACKET_H_
#include "communication/include/network.h"
#include <vector>
#include <stdint.h>
namespace icsneo {
class Packet {
public:
Network network;
std::vector<uint8_t> data;
};
}
#endif
+3 -3
View File
@@ -11,7 +11,7 @@ namespace icsneo {
class Packetizer {
public:
bool input(const std::vector<uint8_t>& bytes);
std::vector<std::shared_ptr<Communication::Packet>> output();
std::vector<std::shared_ptr<Packet>> output();
private:
enum class ReadState {
@@ -27,10 +27,10 @@ private:
int headerSize = 0;
bool checksum = false;
bool gotGoodPackets = false; // Tracks whether we've ever gotten a good packet
Communication::Packet packet;
Packet packet;
std::deque<uint8_t> bytes;
std::vector<std::shared_ptr<Communication::Packet>> processedPackets;
std::vector<std::shared_ptr<Packet>> processedPackets;
};
}