mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 01:18:36 +02:00
Communication: Add LogDataMessage
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "icsneo/communication/message/mdiomessage.h"
|
||||
#include "icsneo/communication/message/extendeddatamessage.h"
|
||||
#include "icsneo/communication/message/livedatamessage.h"
|
||||
#include "icsneo/communication/message/logdatamessage.h"
|
||||
#include "icsneo/communication/message/diskdatamessage.h"
|
||||
#include "icsneo/communication/message/hardwareinfo.h"
|
||||
#include "icsneo/communication/message/tc10statusmessage.h"
|
||||
@@ -491,7 +492,16 @@ bool Decoder::decode(std::shared_ptr<Message>& result, const std::shared_ptr<Pac
|
||||
result = std::make_shared<DiskDataMessage>(std::move(packet->data));
|
||||
return true;
|
||||
}
|
||||
case Network::NetID::Data_To_Host: {
|
||||
result = LogDataMessage::DecodeToMessage(packet->data);
|
||||
if(!result) {
|
||||
report(APIEvent::Type::PacketDecodingError, APIEvent::Severity::EventWarning);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
default:
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "icsneo/communication/message/logdatamessage.h"
|
||||
#include <iostream>
|
||||
|
||||
using namespace icsneo;
|
||||
|
||||
std::shared_ptr<LogDataMessage> LogDataMessage::DecodeToMessage(const std::vector<uint8_t>& bytestream) {
|
||||
if(bytestream.size() % 2 != 0)
|
||||
return nullptr;
|
||||
const auto* begin = (char16_t*)bytestream.data();
|
||||
const auto* end = begin + (bytestream.size() / sizeof(char16_t));
|
||||
return std::make_shared<LogDataMessage>(std::wstring(begin,end));
|
||||
}
|
||||
Reference in New Issue
Block a user