Merge remote-tracking branch 'upstream/mueller/dhb-handle-device-tm-2' into develop

This commit is contained in:
Robin Müller 2022-08-30 23:53:16 +02:00
commit 726f44cafe
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 21 additions and 39 deletions

View File

@ -8,6 +8,7 @@
#include "fsfw/ipc/MessageQueueMessage.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serialize/SerialBufferAdapter.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
#include "fsfw/subsystem/SubsystemBase.h"
@ -1269,40 +1270,33 @@ ReturnValue_t DeviceHandlerBase::letChildHandleMessage(CommandMessage* message)
return returnvalue::FAILED;
}
void DeviceHandlerBase::handleDeviceTm(util::DataWrapper dataWrapper, DeviceCommandId_t replyId,
bool forceDirectTm) {
if (dataWrapper.isNull()) {
return;
}
void DeviceHandlerBase::handleDeviceTm(const uint8_t* rawData, size_t rawDataLen,
DeviceCommandId_t replyId, bool forceDirectTm) {
SerialBufferAdapter bufferWrapper(rawData, rawDataLen);
handleDeviceTm(bufferWrapper, replyId, forceDirectTm);
}
void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t replyId,
bool forceDirectTm) {
auto iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
triggerEvent(DEVICE_UNKNOWN_REPLY, replyId);
return;
}
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()) {
MessageQueueId_t queueId = iter->second.command->second.sendReplyTo;
// This may fail, but we'll ignore the fault.
if (queueId != NO_COMMANDER) {
reportData(queueId);
// This may fail, but we'll ignore the fault.
actionHelper.reportData(queueId, replyId, &dataSet);
}
// This check should make sure we get any TM but don't get anything doubled.
if (wiretappingMode == TM && (requestedRawTraffic != queueId)) {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataWrapper);
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
}
@ -1311,12 +1305,12 @@ void DeviceHandlerBase::handleDeviceTm(util::DataWrapper dataWrapper, DeviceComm
// hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed)
// it is in
reportData(defaultRawReceiver);
actionHelper.reportData(defaultRawReceiver, replyId, &dataSet, true);
}
}
// Unrequested or aperiodic replies
else {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataWrapper);
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
if (wiretappingMode == TM) {
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
}

View File

@ -1070,8 +1070,9 @@ class DeviceHandlerBase : public DeviceHandlerIF,
bool isAwaitingReply();
void handleDeviceTm(util::DataWrapper dataWrapper, DeviceCommandId_t replyId,
void handleDeviceTm(const uint8_t *rawData, size_t rawDataLen, DeviceCommandId_t replyId,
bool forceDirectTm = false);
void handleDeviceTm(SerializeIF &dataSet, DeviceCommandId_t replyId, bool forceDirectTm = false);
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode);

View File

@ -3,8 +3,8 @@
#include "fsfw/serialize/SerializeAdapter.h"
DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId,
util::DataWrapper data)
: objectId(objectId), actionId(actionId), dataWrapper(data) {}
const SerializeIF& data)
: objectId(objectId), actionId(actionId), data(data) {}
DeviceTmReportingWrapper::~DeviceTmReportingWrapper() = default;
@ -19,24 +19,11 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size
if (result != returnvalue::OK) {
return result;
}
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;
return data.serialize(buffer, size, maxSize, streamEndianness);
}
size_t DeviceTmReportingWrapper::getSerializedSize() const {
return sizeof(objectId) + sizeof(ActionId_t) + dataWrapper.getLength();
return sizeof(objectId) + sizeof(ActionId_t) + data.getSerializedSize();
}
ReturnValue_t DeviceTmReportingWrapper::deSerialize(const uint8_t** buffer, size_t* size,

View File

@ -8,7 +8,7 @@
class DeviceTmReportingWrapper : public SerializeIF {
public:
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, util::DataWrapper data);
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, const SerializeIF& data);
~DeviceTmReportingWrapper() override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
@ -19,7 +19,7 @@ class DeviceTmReportingWrapper : public SerializeIF {
private:
object_id_t objectId;
ActionId_t actionId;
util::DataWrapper dataWrapper;
const SerializeIF& data;
// Deserialization forbidden
ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,