Refactor MessageDecoder to Decoder
parent
69773d6537
commit
9f20d70102
|
|
@ -41,7 +41,7 @@ endif()
|
|||
|
||||
set(COMMON_SRC
|
||||
communication/message/neomessage.cpp
|
||||
communication/messagedecoder.cpp
|
||||
communication/decoder.cpp
|
||||
communication/packetizer.cpp
|
||||
communication/multichannelcommunication.cpp
|
||||
communication/communication.cpp
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include "communication/include/command.h"
|
||||
#include "communication/include/messagedecoder.h"
|
||||
#include "communication/include/decoder.h"
|
||||
#include "communication/include/packetizer.h"
|
||||
#include "communication/message/include/serialnumbermessage.h"
|
||||
#include "communication/message/filter/include/main51messagefilter.h"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#include "communication/include/messagedecoder.h"
|
||||
#include "communication/include/decoder.h"
|
||||
#include "communication/include/communication.h"
|
||||
#include "communication/message/include/serialnumbermessage.h"
|
||||
#include "communication/include/command.h"
|
||||
|
|
@ -7,14 +7,14 @@
|
|||
|
||||
using namespace icsneo;
|
||||
|
||||
uint64_t MessageDecoder::GetUInt64FromLEBytes(uint8_t* bytes) {
|
||||
uint64_t Decoder::GetUInt64FromLEBytes(uint8_t* bytes) {
|
||||
uint64_t ret = 0;
|
||||
for(int i = 0; i < 8; i++)
|
||||
ret |= (bytes[i] << (i * 8));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::shared_ptr<Message> MessageDecoder::decodePacket(const std::shared_ptr<Packet>& packet) {
|
||||
std::shared_ptr<Message> Decoder::decodePacket(const std::shared_ptr<Packet>& packet) {
|
||||
switch(packet->network.getType()) {
|
||||
case Network::Type::CAN: {
|
||||
if(packet->data.size() < 24)
|
||||
|
|
@ -8,7 +8,7 @@
|
|||
#include "communication/message/callback/include/messagecallback.h"
|
||||
#include "communication/message/include/serialnumbermessage.h"
|
||||
#include "communication/include/packetizer.h"
|
||||
#include "communication/include/messagedecoder.h"
|
||||
#include "communication/include/decoder.h"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
|
|
@ -20,7 +20,7 @@ namespace icsneo {
|
|||
|
||||
class Communication {
|
||||
public:
|
||||
Communication(std::shared_ptr<ICommunication> com, std::shared_ptr<Packetizer> p, std::shared_ptr<MessageDecoder> md) : impl(com), packetizer(p), decoder(md) {}
|
||||
Communication(std::shared_ptr<ICommunication> com, std::shared_ptr<Packetizer> p, std::shared_ptr<Decoder> md) : impl(com), packetizer(p), decoder(md) {}
|
||||
virtual ~Communication() { close(); }
|
||||
|
||||
bool open();
|
||||
|
|
@ -43,7 +43,7 @@ public:
|
|||
std::shared_ptr<Message> waitForMessageSync(std::shared_ptr<MessageFilter> f, std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||
|
||||
std::shared_ptr<Packetizer> packetizer;
|
||||
std::shared_ptr<MessageDecoder> decoder;
|
||||
std::shared_ptr<Decoder> decoder;
|
||||
|
||||
protected:
|
||||
std::shared_ptr<ICommunication> impl;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#ifndef __MESSAGEDECODER_H_
|
||||
#define __MESSAGEDECODER_H_
|
||||
#ifndef __DECODER_H_
|
||||
#define __DECODER_H_
|
||||
|
||||
#include "communication/message/include/message.h"
|
||||
#include "communication/message/include/canmessage.h"
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace icsneo {
|
||||
|
||||
class MessageDecoder {
|
||||
class Decoder {
|
||||
public:
|
||||
static uint64_t GetUInt64FromLEBytes(uint8_t* bytes);
|
||||
std::shared_ptr<Message> decodePacket(const std::shared_ptr<Packet>& message);
|
||||
|
|
@ -9,7 +9,7 @@ namespace icsneo {
|
|||
|
||||
class MultiChannelCommunication : public Communication {
|
||||
public:
|
||||
MultiChannelCommunication(std::shared_ptr<ICommunication> com, std::shared_ptr<Packetizer> p, std::shared_ptr<MessageDecoder> md) : Communication(com, p, md) {}
|
||||
MultiChannelCommunication(std::shared_ptr<ICommunication> com, std::shared_ptr<Packetizer> p, std::shared_ptr<Decoder> md) : Communication(com, p, md) {}
|
||||
void spawnThreads();
|
||||
void joinThreads();
|
||||
bool sendCommand(Command cmd, std::vector<uint8_t> arguments);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include "communication/include/multichannelcommunication.h"
|
||||
#include "communication/include/command.h"
|
||||
#include "communication/include/messagedecoder.h"
|
||||
#include "communication/include/decoder.h"
|
||||
#include "communication/include/packetizer.h"
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "device/include/idevicesettings.h"
|
||||
#include "communication/include/communication.h"
|
||||
#include "communication/include/packetizer.h"
|
||||
#include "communication/include/messagedecoder.h"
|
||||
#include "communication/include/decoder.h"
|
||||
#include "third-party/concurrentqueue/concurrentqueue.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
NeoOBD2PRO(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<STM32>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
NeoOBD2SIM(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<STM32>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
NeoVIFIRE(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
NeoVIFIRE2ETH(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
auto transport = std::make_shared<PCAP>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
NeoVIFIRE2USB(neodevice_t neodevice) : NeoVIFIRE2(neodevice) {
|
||||
auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
productId = PRODUCT_ID;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
Plasion(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<MultiChannelCommunication>(transport, packetizer, decoder);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#include "device/include/device.h"
|
||||
#include "platform/include/pcap.h"
|
||||
#include "communication/include/packetizer.h"
|
||||
#include "communication/include/messagedecoder.h"
|
||||
#include "communication/include/decoder.h"
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ public:
|
|||
auto packetizer = std::make_shared<Packetizer>();
|
||||
packetizer->disableChecksum = true;
|
||||
packetizer->align16bit = false;
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
RADStar2(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public:
|
|||
auto packetizer = std::make_shared<Packetizer>();
|
||||
packetizer->disableChecksum = true;
|
||||
packetizer->align16bit = false;
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public:
|
|||
ValueCAN3(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<FTDI>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
ValueCAN4(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<STM32>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ public:
|
|||
VividCAN(neodevice_t neodevice) : Device(neodevice) {
|
||||
auto transport = std::make_shared<STM32>(getWritableNeoDevice());
|
||||
auto packetizer = std::make_shared<Packetizer>();
|
||||
auto decoder = std::make_shared<MessageDecoder>();
|
||||
auto decoder = std::make_shared<Decoder>();
|
||||
com = std::make_shared<Communication>(transport, packetizer, decoder);
|
||||
setProductName(PRODUCT_NAME);
|
||||
productId = PRODUCT_ID;
|
||||
|
|
|
|||
Loading…
Reference in New Issue