Health Service Bugfix #617

Merged
gaisser merged 4 commits from mueller/health-srv-bugfix into development 2022-05-09 16:08:29 +02:00
3 changed files with 14 additions and 13 deletions
Showing only changes of commit 4e4820af05 - Show all commits

View File

@ -13,7 +13,7 @@ CService201HealthCommanding::CService201HealthCommanding(object_id_t objectId, u
: CommandingServiceBase(objectId, apid, serviceId, numParallelCommands, commandTimeoutSeconds) {
}
CService201HealthCommanding::~CService201HealthCommanding() {}
CService201HealthCommanding::~CService201HealthCommanding() = default;
gaisser marked this conversation as resolved Outdated

I would move the default to the header and remove the line here but I don't know if this is good practice.

I would move the default to the header and remove the line here but I don't know if this is good practice.

Yeah, I can do that too and I have no idea what the best practice is. I think there is none. If i rewrote a header, I would do it there in the future.

Yeah, I can do that too and I have no idea what the best practice is. I think there is none. If i rewrote a header, I would do it there in the future.

okay, moved to header

okay, moved to header
ReturnValue_t CService201HealthCommanding::isValidSubservice(uint8_t subservice) {
switch (subservice) {
@ -43,8 +43,8 @@ ReturnValue_t CService201HealthCommanding::getMessageQueueAndObject(uint8_t subs
}
ReturnValue_t CService201HealthCommanding::checkInterfaceAndAcquireMessageQueue(
MessageQueueId_t *messageQueueToSet, object_id_t *objectId) {
HasHealthIF *destination = ObjectManager::instance()->get<HasHealthIF>(*objectId);
MessageQueueId_t *messageQueueToSet, const object_id_t *objectId) {
auto *destination = ObjectManager::instance()->get<HasHealthIF>(*objectId);
if (destination == nullptr) {
return CommandingServiceBase::INVALID_OBJECT;
}
@ -77,6 +77,10 @@ ReturnValue_t CService201HealthCommanding::prepareCommand(CommandMessage *messag
HealthMessage::setHealthMessage(message, HealthMessage::HEALTH_ANNOUNCE_ALL);
break;
}
default: {
// Should never happen, subservice was already checked
result = RETURN_FAILED;
}
}
return result;
}
@ -96,9 +100,8 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep
// Not used for now, health state already reported by event
ReturnValue_t CService201HealthCommanding::prepareHealthSetReply(const CommandMessage *reply) {
prepareHealthSetReply(reply);
uint8_t health = static_cast<uint8_t>(HealthMessage::getHealth(reply));
uint8_t oldHealth = static_cast<uint8_t>(HealthMessage::getOldHealth(reply));
auto health = static_cast<uint8_t>(HealthMessage::getHealth(reply));
auto oldHealth = static_cast<uint8_t>(HealthMessage::getOldHealth(reply));
HealthSetReply healthSetReply(health, oldHealth);
return sendTmPacket(Subservice::REPLY_HEALTH_SET, &healthSetReply);
}

View File

@ -1,7 +1,7 @@
#ifndef FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_
#define FSFW_PUS_CSERVICE201HEALTHCOMMANDING_H_
#include "../tmtcservices/CommandingServiceBase.h"
#include "fsfw/tmtcservices/CommandingServiceBase.h"
/**
* @brief Custom PUS service to set health of all objects
@ -21,7 +21,7 @@ class CService201HealthCommanding : public CommandingServiceBase {
public:
CService201HealthCommanding(object_id_t objectId, uint16_t apid, uint8_t serviceId,
uint8_t numParallelCommands = 4, uint16_t commandTimeoutSeconds = 60);
virtual ~CService201HealthCommanding();
~CService201HealthCommanding() override;
protected:
/* CSB abstract function implementations */
@ -38,10 +38,8 @@ class CService201HealthCommanding : public CommandingServiceBase {
bool *isStep) override;
private:
ReturnValue_t checkAndAcquireTargetID(object_id_t *objectIdToSet, const uint8_t *tcData,
size_t tcDataLen);
ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet,
object_id_t *objectId);
static ReturnValue_t checkInterfaceAndAcquireMessageQueue(MessageQueueId_t *MessageQueueToSet,
const object_id_t *objectId);
ReturnValue_t prepareHealthSetReply(const CommandMessage *reply);
gaisser marked this conversation as resolved
Review

[[maybe_unused]] is a c++17 feature

``[[maybe_unused]]`` is a c++17 feature
Review

This is unfortunate. I can't check this if I am using a more recent compiler. WE should consider upgrading the required version to C++17. Every project using the FSFW so far supports it anyway.

This is unfortunate. I can't check this if I am using a more recent compiler. WE should consider upgrading the required version to C++17. Every project using the FSFW so far supports it anyway.

View File

@ -166,7 +166,7 @@ class CommandingServiceBase : public SystemObject,
* @param objectId Target object ID
* @return
* - @c RETURN_OK to generate a verification start message
* - @c EXECUTION_COMPELTE Fire-and-forget command. Generate a completion
* - @c EXECUTION_COMPLETE Fire-and-forget command. Generate a completion
* verification message.
* - @c Anything else rejects the packets and generates a start failure
* verification.