Communication: Add LogDataMessage

This commit is contained in:
Keith Nash
2025-05-16 19:36:27 +00:00
committed by Kyle Schwarz
parent b94ade1ef6
commit b3d47f2ae5
10 changed files with 63 additions and 0 deletions
+10
View File
@@ -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;
+12
View File
@@ -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));
}