Merge pull request 'CSB improvements' (#143) from KSat/fsfw:mueller/feature/CSBupdate into master

This commit is contained in:
Steffen Gaisser 2020-08-12 10:05:43 +02:00
commit 18105e2d16
2 changed files with 79 additions and 31 deletions

View File

@ -8,18 +8,28 @@
#include <framework/tmtcpacket/pus/TcPacketStored.h> #include <framework/tmtcpacket/pus/TcPacketStored.h>
#include <framework/tmtcpacket/pus/TmPacketStored.h> #include <framework/tmtcpacket/pus/TmPacketStored.h>
object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId, CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId,
uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands, uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeoutSeconds, object_id_t setPacketSource, uint16_t commandTimeoutSeconds, size_t queueDepth) :
object_id_t setPacketDestination, size_t queueDepth) :
SystemObject(setObjectId), apid(apid), service(service), SystemObject(setObjectId), apid(apid), service(service),
timeoutSeconds(commandTimeoutSeconds), timeoutSeconds(commandTimeoutSeconds),
commandMap(numberOfParallelCommands), packetSource(setPacketSource), commandMap(numberOfParallelCommands) {
packetDestination(setPacketDestination) {
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth); commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth); requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
} }
void CommandingServiceBase::setPacketSource(object_id_t packetSource) {
this->packetSource = packetSource;
}
void CommandingServiceBase::setPacketDestination(
object_id_t packetDestination) {
this->packetDestination = packetDestination;
}
CommandingServiceBase::~CommandingServiceBase() { CommandingServiceBase::~CommandingServiceBase() {
QueueFactory::instance()->deleteMessageQueue(commandQueue); QueueFactory::instance()->deleteMessageQueue(commandQueue);
@ -52,10 +62,18 @@ ReturnValue_t CommandingServiceBase::initialize() {
return result; return result;
} }
if(packetDestination == objects::NO_OBJECT) {
packetDestination = defaultPacketDestination;
}
AcceptsTelemetryIF* packetForwarding = AcceptsTelemetryIF* packetForwarding =
objectManager->get<AcceptsTelemetryIF>(packetDestination); objectManager->get<AcceptsTelemetryIF>(packetDestination);
if(packetSource == objects::NO_OBJECT) {
packetSource = defaultPacketSource;
}
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>( PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
packetSource); packetSource);
if (packetForwarding == nullptr or distributor == nullptr) { if (packetForwarding == nullptr or distributor == nullptr) {
sif::error << "CommandingServiceBase::intialize: Packet source or " sif::error << "CommandingServiceBase::intialize: Packet source or "
"packet destination invalid!" << std::endl; "packet destination invalid!" << std::endl;
@ -108,11 +126,11 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
&nextCommand, iter->objectId, &isStep); &nextCommand, iter->objectId, &isStep);
/* If the child implementation does not implement special handling for /* If the child implementation does not implement special handling for
* rejected replies (RETURN_FAILED is returned), a failure verification * rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a
* will be generated with the reason as the return code and the initial * failure verification will be generated with the reason as the
* command as failure parameter 1 */ * return code and the initial command as failure parameter 1 */
if(reply->getCommand() == CommandMessage::REPLY_REJECTED and if((reply->getCommand() == CommandMessage::REPLY_REJECTED) and
result == RETURN_FAILED) { (result == RETURN_FAILED or result == INVALID_REPLY)) {
result = reply->getReplyRejectedReason(); result = reply->getReplyRejectedReason();
failureParameter1 = iter->command; failureParameter1 = iter->command;
} }

View File

@ -15,6 +15,10 @@
class TcPacketStored; class TcPacketStored;
namespace Factory{
void setStaticFrameworkObjectIds();
}
/** /**
* @brief This class is the basis for all PUS Services, which have to * @brief This class is the basis for all PUS Services, which have to
* relay Telecommands to software bus. * relay Telecommands to software bus.
@ -33,6 +37,7 @@ class CommandingServiceBase: public SystemObject,
public AcceptsTelecommandsIF, public AcceptsTelecommandsIF,
public ExecutableObjectIF, public ExecutableObjectIF,
public HasReturnvaluesIF { public HasReturnvaluesIF {
friend void (Factory::setStaticFrameworkObjectIds)();
public: public:
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE; static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE;
static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1); static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1);
@ -57,10 +62,24 @@ public:
*/ */
CommandingServiceBase(object_id_t setObjectId, uint16_t apid, CommandingServiceBase(object_id_t setObjectId, uint16_t apid,
uint8_t service, uint8_t numberOfParallelCommands, uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeoutSeconds, object_id_t setPacketSource, uint16_t commandTimeoutSeconds, size_t queueDepth = 20);
object_id_t setPacketDestination, size_t queueDepth = 20);
virtual ~CommandingServiceBase(); virtual ~CommandingServiceBase();
/**
* This setter can be used to set the packet source individually instead
* of using the default static framework ID set in the factory.
* This should be called at object initialization and not during run-time!
* @param packetSource
*/
void setPacketSource(object_id_t packetSource);
/**
* This setter can be used to set the packet destination individually
* instead of using the default static framework ID set in the factory.
* This should be called at object initialization and not during run-time!
* @param packetDestination
*/
void setPacketDestination(object_id_t packetDestination);
/*** /***
* This is the periodically called function. * This is the periodically called function.
* Handle request queue for external commands. * Handle request queue for external commands.
@ -68,7 +87,7 @@ public:
* @param opCode is unused here at the moment * @param opCode is unused here at the moment
* @return RETURN_OK * @return RETURN_OK
*/ */
virtual ReturnValue_t performOperation(uint8_t opCode); virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual uint16_t getIdentifier(); virtual uint16_t getIdentifier();
@ -89,22 +108,23 @@ public:
*/ */
virtual MessageQueueId_t getCommandQueue(); virtual MessageQueueId_t getCommandQueue();
virtual ReturnValue_t initialize(); virtual ReturnValue_t initialize() override;
/** /**
* Implementation of ExecutableObjectIF function * Implementation of ExecutableObjectIF function
* *
* Used to setup the reference of the task, that executes this component * Used to setup the reference of the task, that executes this component
* @param task_ Pointer to the taskIF of this task * @param task Pointer to the taskIF of this task
*/ */
virtual void setTaskIF(PeriodicTaskIF* task_); virtual void setTaskIF(PeriodicTaskIF* task) override;
protected: protected:
/** /**
* Check the target subservice * Check the target subservice
* @param subservice[in] * @param subservice[in]
* @return -@c RETURN_OK on success * @return
* -@c INVALID_SUBSERVICE if service is not known * -@c RETURN_OK Subservice valid, continue message handling
* -@c INVALID_SUBSERVICE if service is not known, rejects packet.
*/ */
virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0; virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0;
@ -117,9 +137,10 @@ protected:
* @param tcDataLen * @param tcDataLen
* @param id MessageQueue ID is stored here * @param id MessageQueue ID is stored here
* @param objectId Object ID is extracted and stored here * @param objectId Object ID is extracted and stored here
* @return - @c RETURN_OK on success * @return
* - @c RETURN_FAILED * - @c RETURN_OK Cotinue message handling
* - @c CSB or implementation specific return codes * - @c RETURN_FAILED Reject the packet and generates a start failure
* verification
*/ */
virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice, virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id, const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
@ -138,6 +159,11 @@ protected:
* communication * communication
* @param objectId Target object ID * @param objectId Target object ID
* @return * @return
* - @c RETURN_OK to generate a verification start message
* - @c EXECUTION_COMPELTE Fire-and-forget command. Generate a completion
* verification message.
* - @c Anything else rejects the packets and generates a start failure
* verification.
*/ */
virtual ReturnValue_t prepareCommand(CommandMessage* message, virtual ReturnValue_t prepareCommand(CommandMessage* message,
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen, uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
@ -160,11 +186,12 @@ protected:
* @return * @return
* - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to * - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to
* generate TC verification success * generate TC verification success
* - @c INVALID_REPLY calls handleUnrequestedReply * - @c INVALID_REPLY Calls handleUnrequestedReply
* - Anything else triggers a TC verification failure. If RETURN_FAILED * - Anything else triggers a TC verification failure. If RETURN_FAILED or
* is returned and the command ID is CommandMessage::REPLY_REJECTED, * INVALID_REPLY is returned and the command ID is
* a failure verification message with the reason as the error parameter * CommandMessage::REPLY_REJECTED, a failure verification message with
* and the initial command as failure parameter 1. * the reason as the error parameter and the initial command as
* failure parameter 1 is generated.
*/ */
virtual ReturnValue_t handleReply(const CommandMessage* reply, virtual ReturnValue_t handleReply(const CommandMessage* reply,
Command_t previousCommand, uint32_t *state, Command_t previousCommand, uint32_t *state,
@ -227,9 +254,10 @@ protected:
uint32_t failureParameter1 = 0; uint32_t failureParameter1 = 0;
uint32_t failureParameter2 = 0; uint32_t failureParameter2 = 0;
object_id_t packetSource; static object_id_t defaultPacketSource;
object_id_t packetSource = objects::NO_OBJECT;
object_id_t packetDestination; static object_id_t defaultPacketDestination;
object_id_t packetDestination = objects::NO_OBJECT;
/** /**
* Pointer to the task which executes this component, * Pointer to the task which executes this component,
@ -274,7 +302,6 @@ protected:
void checkAndExecuteFifo(CommandMapIter iter); void checkAndExecuteFifo(CommandMapIter iter);
private: private:
/** /**
* This method handles internal execution of a command, * This method handles internal execution of a command,
* once it has been started by @sa{startExecution()} in the request * once it has been started by @sa{startExecution()} in the request
@ -294,10 +321,13 @@ private:
void handleCommandQueue(); void handleCommandQueue();
/** /**
* @brief Handler function for request queue
* @details
* Sequence of request queue handling: * Sequence of request queue handling:
* isValidSubservice -> getMessageQueueAndObject -> startExecution * isValidSubservice -> getMessageQueueAndObject -> startExecution
* Generates Start Success Reports TM[1,3] in subfunction @sa{startExecution()} * Generates a Start Success Reports TM[1,3] in subfunction
* or Start Failure Report TM[1,4] by using the TC Verification Service * @sa{startExecution()} or a Start Failure Report TM[1,4] by using the
* TC Verification Service.
*/ */
void handleRequestQueue(); void handleRequestQueue();