mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Communication::Packet refactored out to Packet
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user