mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Communication: Add LogDataMessage
This commit is contained in:
@@ -246,6 +246,7 @@ set(SRC_FILES
|
||||
communication/message/ethphymessage.cpp
|
||||
communication/message/linmessage.cpp
|
||||
communication/message/livedatamessage.cpp
|
||||
communication/message/logdatamessage.cpp
|
||||
communication/message/tc10statusmessage.cpp
|
||||
communication/message/gptpstatusmessage.cpp
|
||||
communication/message/ethernetstatusmessage.cpp
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
@@ -405,6 +405,14 @@ bool Device::close() {
|
||||
return com->close();
|
||||
}
|
||||
|
||||
bool Device::enableLogData() {
|
||||
return com->sendCommand(Command::EnableLogData, true);
|
||||
}
|
||||
|
||||
bool Device::disableLogData() {
|
||||
return com->sendCommand(Command::EnableLogData, false);
|
||||
}
|
||||
|
||||
bool Device::goOnline() {
|
||||
if(!enableNetworkCommunication(true))
|
||||
return false;
|
||||
|
||||
@@ -38,6 +38,7 @@ enum class Command : uint8_t {
|
||||
FlexRayControl = 0xF3,
|
||||
CoreMiniPreload = 0xF4, // Previously known as RED_CMD_COREMINI_PRELOAD
|
||||
PHYControlRegisters = 0xEF,
|
||||
EnableLogData = 0xF6,
|
||||
};
|
||||
|
||||
enum class ExtendedCommand : uint16_t {
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#ifndef __LOGDATAMESSAGE_H_
|
||||
#define __LOGDATAMESSAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class LogDataMessage : public RawMessage {
|
||||
public:
|
||||
static std::shared_ptr<LogDataMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
|
||||
LogDataMessage(std::wstring logDataString) :
|
||||
RawMessage(Message::Type::LogData, Network::NetID::Data_To_Host), logMessage(logDataString) {}
|
||||
|
||||
std::wstring logMessage;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
AppError = 0x8012,
|
||||
GPTPStatus = 0x8013,
|
||||
EthernetStatus = 0x8014,
|
||||
LogData = 0x8015,
|
||||
};
|
||||
|
||||
Message(Type t) : type(t) {}
|
||||
|
||||
@@ -583,6 +583,7 @@ public:
|
||||
case NetID::RED_GET_RTC:
|
||||
case NetID::DiskData:
|
||||
case NetID::RED_App_Error:
|
||||
case NetID::Data_To_Host:
|
||||
return Type::Internal;
|
||||
case NetID::Invalid:
|
||||
case NetID::Any:
|
||||
|
||||
@@ -151,6 +151,8 @@ public:
|
||||
virtual bool isDisconnected() const { return com->isDisconnected(); }
|
||||
virtual bool goOnline();
|
||||
virtual bool goOffline();
|
||||
virtual bool enableLogData();
|
||||
virtual bool disableLogData();
|
||||
|
||||
enum class PreloadReturn : uint8_t
|
||||
{
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "icsneo/communication/message/a2bmessage.h"
|
||||
#include "icsneo/communication/message/linmessage.h"
|
||||
#include "icsneo/communication/message/mdiomessage.h"
|
||||
#include "icsneo/communication/message/logdatamessage.h"
|
||||
|
||||
#include "icsneo/communication/message/callback/streamoutput/a2bwavoutput.h"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user