EIVE upstream #29

Merged
muellerr merged 693 commits from use-eive-upstream into develop 2023-06-30 15:44:39 +02:00
4 changed files with 57 additions and 46 deletions
Showing only changes of commit 3a47062f2a - Show all commits

View File

@ -1257,30 +1257,40 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message)
return returnvalue::FAILED; return returnvalue::FAILED;
} }
void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t replyId, void DeviceHandlerBase::handleDeviceTm(util::DataWrapper dataWrapper, DeviceCommandId_t replyId,
bool forceDirectTm) { bool forceDirectTm) {
if (dataSet == nullptr) { if (dataWrapper.isNull()) {
return; return;
} }
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); auto iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) { if (iter == deviceReplyMap.end()) {
triggerEvent(DEVICE_UNKNOWN_REPLY, replyId); triggerEvent(DEVICE_UNKNOWN_REPLY, replyId);
return; return;
} }
/* Regular replies to a command */ auto reportData = [&](MessageQueueId_t queueId) {
if (dataWrapper.type == util::DataTypes::SERIALIZABLE) {
return actionHelper.reportData(queueId, replyId, dataWrapper.dataUnion.serializable);
} else if (dataWrapper.type == util::DataTypes::RAW) {
return actionHelper.reportData(queueId, replyId, dataWrapper.dataUnion.raw.data,
dataWrapper.dataUnion.raw.len);
}
return returnvalue::FAILED;
};
// Regular replies to a command
if (iter->second.command != deviceCommandMap.end()) { if (iter->second.command != deviceCommandMap.end()) {
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo; MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
// This may fail, but we'll ignore the fault.
if (queueId != NO_COMMANDER) { if (queueId != NO_COMMANDER) {
/* This may fail, but we'll ignore the fault. */ reportData(queueId);
actionHelper.reportData(queueId, replyId, dataSet);
} }
/* This check should make sure we get any TM but don't get anything doubled. */ // This check should make sure we get any TM but don't get anything doubled.
if (wiretappingMode == TM && (requestedRawTraffic != queueId)) { if (wiretappingMode == TM && (requestedRawTraffic != queueId)) {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataWrapper);
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
} }
@ -1289,22 +1299,16 @@ void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t r
// hiding of sender needed so the service will handle it as // hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed) // unexpected Data, no matter what state (progress or completed)
// it is in // it is in
actionHelper.reportData(defaultRawReceiver, replyId, dataSet, true); reportData(defaultRawReceiver);
} }
} }
/* Unrequested or aperiodic replies */ // Unrequested or aperiodic replies
else { else {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataWrapper);
if (wiretappingMode == TM) { if (wiretappingMode == TM) {
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
} }
if (forceDirectTm and defaultRawReceiver != MessageQueueIF::NO_QUEUE) { if (forceDirectTm and defaultRawReceiver != MessageQueueIF::NO_QUEUE) {
// sid_t setSid = sid_t(this->getObjectId(), replyId);
// LocalPoolDataSetBase* dataset = getDataSetHandle(setSid);
// if(dataset != nullptr) {
// poolManager.generateHousekeepingPacket(setSid, dataset, true);
// }
// hiding of sender needed so the service will handle it as // hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed) // unexpected Data, no matter what state (progress or completed)
// it is in // it is in

View File

@ -23,6 +23,7 @@
#include "fsfw/serviceinterface/serviceInterfaceDefintions.h" #include "fsfw/serviceinterface/serviceInterfaceDefintions.h"
#include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/tasks/ExecutableObjectIF.h"
#include "fsfw/tasks/PeriodicTaskIF.h" #include "fsfw/tasks/PeriodicTaskIF.h"
#include "fsfw/util/dataWrapper.h"
namespace Factory { namespace Factory {
void setStaticFrameworkObjectIds(); void setStaticFrameworkObjectIds();
@ -1052,9 +1053,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
bool isAwaitingReply(); bool isAwaitingReply();
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); void handleDeviceTm(util::DataWrapper dataWrapper, DeviceCommandId_t replyId,
// void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId, bool forceDirectTm = false);
// bool forceDirectTm);
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode); uint32_t *msToReachTheMode);

View File

@ -3,10 +3,10 @@
#include "fsfw/serialize/SerializeAdapter.h" #include "fsfw/serialize/SerializeAdapter.h"
DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId,
SerializeIF* data) util::DataWrapper data)
: objectId(objectId), actionId(actionId), data(data) {} : objectId(objectId), actionId(actionId), dataWrapper(data) {}
DeviceTmReportingWrapper::~DeviceTmReportingWrapper() {} DeviceTmReportingWrapper::~DeviceTmReportingWrapper() = default;
ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size, size_t maxSize, ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const { Endianness streamEndianness) const {
@ -19,22 +19,27 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
return data->serialize(buffer, size, maxSize, streamEndianness); if (dataWrapper.isNull()) {
return returnvalue::FAILED;
}
if (dataWrapper.type == util::DataTypes::SERIALIZABLE) {
return dataWrapper.dataUnion.serializable->serialize(buffer, size, maxSize, streamEndianness);
} else if (dataWrapper.type == util::DataTypes::RAW) {
if (*size + dataWrapper.dataUnion.raw.len > maxSize) {
return SerializeIF::BUFFER_TOO_SHORT;
}
std::memcpy(*buffer, dataWrapper.dataUnion.raw.data, dataWrapper.dataUnion.raw.len);
*buffer += dataWrapper.dataUnion.raw.len;
*size += dataWrapper.dataUnion.raw.len;
}
return returnvalue::OK;
} }
size_t DeviceTmReportingWrapper::getSerializedSize() const { size_t DeviceTmReportingWrapper::getSerializedSize() const {
return sizeof(objectId) + sizeof(ActionId_t) + data->getSerializedSize(); return sizeof(objectId) + sizeof(ActionId_t) + dataWrapper.getLength();
} }
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size, ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) { Endianness streamEndianness) {
ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness); return returnvalue::FAILED;
if (result != returnvalue::OK) {
return result;
}
result = SerializeAdapter::deSerialize(&actionId, buffer, size, streamEndianness);
if (result != returnvalue::OK) {
return result;
}
return data->deSerialize(buffer, size, streamEndianness);
} }

View File

@ -1,27 +1,29 @@
#ifndef FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ #ifndef FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
#define FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ #define FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_
#include "../action/HasActionsIF.h" #include "fsfw/action/HasActionsIF.h"
#include "../objectmanager/SystemObjectIF.h" #include "fsfw/objectmanager/SystemObjectIF.h"
#include "../serialize/SerializeIF.h" #include "fsfw/serialize/SerializeIF.h"
#include "fsfw/util/dataWrapper.h"
class DeviceTmReportingWrapper : public SerializeIF { class DeviceTmReportingWrapper : public SerializeIF {
public: public:
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, SerializeIF* data); DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, util::DataWrapper data);
virtual ~DeviceTmReportingWrapper(); ~DeviceTmReportingWrapper() override;
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override; Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override; [[nodiscard]] size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
private: private:
object_id_t objectId; object_id_t objectId;
ActionId_t actionId; ActionId_t actionId;
SerializeIF* data; util::DataWrapper dataWrapper;
// Deserialization forbidden
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
}; };
#endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */ #endif /* FSFW_DEVICEHANDLERS_DEVICETMREPORTINGWRAPPER_H_ */