const correct API

This commit is contained in:
Robin Müller 2022-08-31 00:02:25 +02:00
parent ab719a3e59
commit 158007fa7f
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC
4 changed files with 23 additions and 28 deletions

View File

@ -1264,7 +1264,7 @@ void DeviceHandlerBase::handleDeviceTm(const uint8_t* rawData, size_t rawDataLen
handleDeviceTm(bufferWrapper, replyId, forceDirectTm);
}
void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t replyId,
void DeviceHandlerBase::handleDeviceTm(const SerializeIF& dataSet, DeviceCommandId_t replyId,
bool forceDirectTm) {
auto iter = deviceReplyMap.find(replyId);
if (iter == deviceReplyMap.end()) {
@ -1278,12 +1278,12 @@ void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t r
if (queueId != NO_COMMANDER) {
// 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.
if (wiretappingMode == TM && (requestedRawTraffic != queueId)) {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, &dataSet);
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
}
@ -1292,12 +1292,13 @@ void DeviceHandlerBase::handleDeviceTm(SerializeIF& dataSet, DeviceCommandId_t r
// hiding of sender needed so the service will handle it as
// unexpected Data, no matter what state (progress or completed)
// it is in
actionHelper.reportData(defaultRawReceiver, replyId, &dataSet, true);
actionHelper.reportData(defaultRawReceiver, replyId, const_cast<SerializeIF*>(&dataSet),
true);
}
}
// Unrequested or aperiodic replies
else {
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, &dataSet);
DeviceTmReportingWrapper wrapper(getObjectId(), replyId, dataSet);
if (wiretappingMode == TM) {
actionHelper.reportData(requestedRawTraffic, replyId, &wrapper);
}

View File

@ -1054,7 +1054,8 @@ class DeviceHandlerBase : public DeviceHandlerIF,
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);
void handleDeviceTm(const SerializeIF &dataSet, DeviceCommandId_t replyId,
bool forceDirectTm = false);
virtual ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode);

View File

@ -3,10 +3,10 @@
#include "fsfw/serialize/SerializeAdapter.h"
DeviceTmReportingWrapper::DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId,
SerializeIF* data)
const SerializeIF& 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,
Endianness streamEndianness) const {
@ -19,22 +19,14 @@ ReturnValue_t DeviceTmReportingWrapper::serialize(uint8_t** buffer, size_t* size
if (result != returnvalue::OK) {
return result;
}
return data->serialize(buffer, size, maxSize, streamEndianness);
return data.serialize(buffer, size, maxSize, streamEndianness);
}
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,
Endianness streamEndianness) {
ReturnValue_t result = SerializeAdapter::deSerialize(&objectId, buffer, size, streamEndianness);
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);
return returnvalue::FAILED;
}

View File

@ -7,21 +7,22 @@
class DeviceTmReportingWrapper : public SerializeIF {
public:
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, SerializeIF* data);
virtual ~DeviceTmReportingWrapper();
DeviceTmReportingWrapper(object_id_t objectId, ActionId_t actionId, const SerializeIF& data);
~DeviceTmReportingWrapper() override;
virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize,
Endianness streamEndianness) const override;
virtual size_t getSerializedSize() const override;
virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size,
Endianness streamEndianness) override;
[[nodiscard]] size_t getSerializedSize() const override;
private:
object_id_t objectId;
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_ */