Merge pull request 'DHB TM handler alternative API raw buffer' (#671) from mueller/dhb-handle-device-tm-2 into development

Reviewed-on: fsfw/fsfw#671
This commit is contained in:
Ulrich Mohr 2022-09-01 11:22:17 +02:00
commit 60fd3d43c0
4 changed files with 50 additions and 43 deletions

View File

@ -8,6 +8,7 @@
#include "fsfw/ipc/MessageQueueMessage.h" #include "fsfw/ipc/MessageQueueMessage.h"
#include "fsfw/ipc/QueueFactory.h" #include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h" #include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serialize/SerialBufferAdapter.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/subsystem/SubsystemBase.h" #include "fsfw/subsystem/SubsystemBase.h"
@ -1257,28 +1258,30 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message)
return returnvalue::FAILED; return returnvalue::FAILED;
} }
void DeviceHandlerBase::handleDeviceTM(SerializeIF* dataSet, DeviceCommandId_t replyId, void DeviceHandlerBase::handleDeviceTm(const uint8_t* rawData, size_t rawDataLen,
bool forceDirectTm) { DeviceCommandId_t replyId, bool forceDirectTm) {
if (dataSet == nullptr) { SerialBufferAdapter bufferWrapper(rawData, rawDataLen);
return; handleDeviceTm(bufferWrapper, replyId, forceDirectTm);
} }
DeviceReplyMap::iterator iter = deviceReplyMap.find(replyId); void DeviceHandlerBase::handleDeviceTm(const SerializeIF& dataSet, DeviceCommandId_t replyId,
bool forceDirectTm) {
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 */ // 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;
if (queueId != NO_COMMANDER) { if (queueId != NO_COMMANDER) {
/* This may fail, but we'll ignore the fault. */ // This may fail, but we'll ignore the fault.
actionHelper.reportData(queueId, replyId, dataSet); actionHelper.reportData(queueId, replyId, const_cast<SerializeIF*>(&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, dataSet);
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper); actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
@ -1289,22 +1292,17 @@ 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); actionHelper.reportData(defaultRawReceiver, replyId, const_cast<SerializeIF*>(&dataSet),
true);
} }
} }
/* Unrequested or aperiodic replies */ // Unrequested or aperiodic replies
else { else {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet); DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
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

@ -1052,9 +1052,25 @@ class DeviceHandlerBase : public DeviceHandlerIF,
bool isAwaitingReply(); bool isAwaitingReply();
void handleDeviceTM(SerializeIF *dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false); /**
// void handleDeviceTM(uint8_t* data, size_t dataSize, DeviceCommandId_t replyId, * Wrapper function for @handleDeviceTm which wraps the raw buffer with @SerialBufferAdapter.
// bool forceDirectTm); * For interpreted data, prefer the other function.
* @param rawData
* @param rawDataLen
* @param replyId
* @param forceDirectTm
*/
void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId,
bool forceDirectTm = false);
/**
* Can be used to handle Service 8 data replies. This will also generate the TM wiretapping
* packets accordingly.
* @param dataSet
* @param replyId
* @param forceDirectTm
*/
void handleDeviceTm(const SerializeIF &dataSet, DeviceCommandId_t replyId,
bool forceDirectTm = false);
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) const SerializeIF& data)
: objectId(objectId), actionId(actionId), data(data) {} : objectId(objectId), actionId(actionId), data(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,14 @@ 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); return data.serialize(buffer, size, maxSize, streamEndianness);
} }
size_t DeviceTmReportingWrapper::getSerializedSize() const { size_t DeviceTmReportingWrapper::getSerializedSize() const {
return sizeof(objectId) + sizeof(ActionId_t) + data->getSerializedSize(); return sizeof(objectId) + sizeof(ActionId_t) + data.getSerializedSize();
} }
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

@ -7,21 +7,22 @@
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, const SerializeIF& 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; const SerializeIF& data;
// 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_ */