WIP: CFDP Init #512
60
src/fsfw/cfdp/CFDPHandler.cpp
Normal file
60
src/fsfw/cfdp/CFDPHandler.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
#include <fsfw/src/fsfw/ipc/CommandMessage.h>
|
||||
#include <fsfw/src/fsfw/storagemanager/storeAddress.h>
|
||||
#include "fsfw/cfdp/CFDPHandler.h"
|
||||
#include "fsfw/cfdp/CFDPMessage.h"
|
||||
|
||||
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
|
||||
#include "fsfw/ipc/QueueFactory.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
object_id_t CFDPHandler::packetSource = 0;
|
||||
object_id_t CFDPHandler::packetDestination = 0;
|
||||
|
||||
CFDPHandler::CFDPHandler(object_id_t setObjectId, CFDPDistributor* dist) : SystemObject(setObjectId) {
|
||||
requestQueue = QueueFactory::instance()->createMessageQueue(CFDP_HANDLER_MAX_RECEPTION);
|
||||
distributor = dist;
|
||||
}
|
||||
|
||||
CFDPHandler::~CFDPHandler() {}
|
||||
|
||||
ReturnValue_t CFDPHandler::initialize() {
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
this->distributor->registerHandler(this);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CFDPHandler::handleRequest(store_address_t storeId) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "CFDPHandler::handleRequest" << std::endl;
|
||||
#else
|
||||
sif::printDebug("CFDPHandler::handleRequest\n");
|
||||
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif
|
||||
|
||||
//TODO read out packet from store using storeId
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CFDPHandler::performOperation(uint8_t opCode) {
|
||||
ReturnValue_t status = RETURN_OK;
|
||||
CommandMessage currentMessage;
|
||||
for (status = this->requestQueue->receiveMessage(¤tMessage); status == RETURN_OK;
|
||||
status = this->requestQueue->receiveMessage(¤tMessage)) {
|
||||
store_address_t storeId = CFDPMessage::getStoreId(¤tMessage);
|
||||
this->handleRequest(storeId);
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
uint16_t CFDPHandler::getIdentifier() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
MessageQueueId_t CFDPHandler::getRequestQueue() {
|
||||
return this->requestQueue->getId();
|
||||
}
|
62
src/fsfw/cfdp/CFDPHandler.h
Normal file
62
src/fsfw/cfdp/CFDPHandler.h
Normal file
@ -0,0 +1,62 @@
|
||||
#ifndef FSFW_CFDP_CFDPHANDLER_H_
|
||||
#define FSFW_CFDP_CFDPHANDLER_H_
|
||||
|
||||
#include "fsfw/tmtcservices/AcceptsTelecommandsIF.h"
|
||||
#include "fsfw/objectmanager/SystemObject.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
#include "fsfw/tasks/ExecutableObjectIF.h"
|
||||
#include "fsfw/tcdistribution/CFDPDistributor.h"
|
||||
|
||||
#include "fsfw/ipc/MessageQueueIF.h"
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
}
|
||||
|
||||
class CFDPHandler :
|
||||
public ExecutableObjectIF,
|
||||
public AcceptsTelecommandsIF,
|
||||
public SystemObject,
|
||||
public HasReturnvaluesIF {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
CFDPHandler(object_id_t setObjectId, CFDPDistributor* distributor);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~CFDPHandler();
|
||||
|
||||
virtual ReturnValue_t handleRequest(store_address_t storeId);
|
||||
|
||||
virtual ReturnValue_t initialize() override;
|
||||
virtual uint16_t getIdentifier() override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
protected:
|
||||
/**
|
||||
* This is a complete instance of the telecommand reception queue
|
||||
* of the class. It is initialized on construction of the class.
|
||||
*/
|
||||
MessageQueueIF* requestQueue = nullptr;
|
||||
|
||||
CFDPDistributor* distributor = nullptr;
|
||||
|
||||
/**
|
||||
* The current CFDP packet to be processed.
|
||||
* It is deleted after handleRequest was executed.
|
||||
*/
|
||||
CFDPPacketStored currentPacket;
|
||||
|
||||
static object_id_t packetSource;
|
||||
|
||||
static object_id_t packetDestination;
|
||||
private:
|
||||
/**
|
||||
* This constant sets the maximum number of packets accepted per call.
|
||||
* Remember that one packet must be completely handled in one
|
||||
* #handleRequest call.
|
||||
*/
|
||||
static const uint8_t CFDP_HANDLER_MAX_RECEPTION = 100;
|
||||
};
|
||||
|
||||
#endif /* FSFW_CFDP_CFDPHANDLER_H_ */
|
21
src/fsfw/cfdp/CFDPMessage.cpp
Normal file
21
src/fsfw/cfdp/CFDPMessage.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
#include "CFDPMessage.h"
|
||||
|
||||
CFDPMessage::CFDPMessage() {
|
||||
}
|
||||
|
||||
CFDPMessage::~CFDPMessage() {
|
||||
}
|
||||
|
||||
void CFDPMessage::setCommand(CommandMessage *message,
|
||||
store_address_t cfdpPacket) {
|
||||
message->setParameter(cfdpPacket.raw);
|
||||
}
|
||||
|
||||
store_address_t CFDPMessage::getStoreId(const CommandMessage *message) {
|
||||
store_address_t storeAddressCFDPPacket;
|
||||
storeAddressCFDPPacket = message->getParameter();
|
||||
return storeAddressCFDPPacket;
|
||||
}
|
||||
|
||||
void CFDPMessage::clear(CommandMessage *message) {
|
||||
}
|
23
src/fsfw/cfdp/CFDPMessage.h
Normal file
23
src/fsfw/cfdp/CFDPMessage.h
Normal file
@ -0,0 +1,23 @@
|
||||
#ifndef FSFW_CFDP_CFDPMESSAGE_H_
|
||||
#define FSFW_CFDP_CFDPMESSAGE_H_
|
||||
|
||||
#include "fsfw/ipc/CommandMessage.h"
|
||||
#include "fsfw/objectmanager/ObjectManagerIF.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
|
||||
class CFDPMessage {
|
||||
private:
|
||||
CFDPMessage();
|
||||
public:
|
||||
static const uint8_t MESSAGE_ID = messagetypes::CFDP;
|
||||
|
||||
virtual ~CFDPMessage();
|
||||
static void setCommand(CommandMessage* message,
|
||||
store_address_t cfdpPacket);
|
||||
|
||||
static store_address_t getStoreId(const CommandMessage* message);
|
||||
|
||||
static void clear(CommandMessage* message);
|
||||
};
|
||||
|
||||
#endif /* FSFW_CFDP_CFDPMESSAGE_H_ */
|
4
src/fsfw/cfdp/CMakeLists.txt
Normal file
4
src/fsfw/cfdp/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
CFDPHandler.cpp
|
||||
CFDPMessage.cpp
|
||||
)
|
@ -19,6 +19,9 @@ enum framework_objects: object_id_t {
|
||||
PUS_SERVICE_200_MODE_MGMT = 0x53000200,
|
||||
PUS_SERVICE_201_HEALTH = 0x53000201,
|
||||
|
||||
/* CFDP Distributer */
|
||||
CFDP_PACKET_DISTRIBUTOR = 0x53001000,
|
||||
|
||||
//Generic IDs for IPC, modes, health, events
|
||||
HEALTH_TABLE = 0x53010000,
|
||||
// MODE_STORE = 0x53010100,
|
||||
|
@ -7,8 +7,8 @@
|
||||
#define CCSDS_DISTRIBUTOR_DEBUGGING 0
|
||||
|
||||
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid,
|
||||
object_id_t setObjectId):
|
||||
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
|
||||
object_id_t setObjectId):
|
||||
TcDistributor(setObjectId), defaultApid( setDefaultApid ) {
|
||||
}
|
||||
|
||||
CCSDSDistributor::~CCSDSDistributor() {}
|
||||
@ -16,97 +16,97 @@ CCSDSDistributor::~CCSDSDistributor() {}
|
||||
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
|
||||
#if CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "CCSDSDistributor::selectDestination received: " <<
|
||||
this->currentMessage.getStorageId().poolIndex << ", " <<
|
||||
this->currentMessage.getStorageId().packetIndex << std::endl;
|
||||
sif::debug << "CCSDSDistributor::selectDestination received: " <<
|
||||
this->currentMessage.getStorageId().poolIndex << ", " <<
|
||||
this->currentMessage.getStorageId().packetIndex << std::endl;
|
||||
#else
|
||||
sif::printDebug("CCSDSDistributor::selectDestination received: %d, %d\n",
|
||||
currentMessage.getStorageId().poolIndex, currentMessage.getStorageId().packetIndex);
|
||||
sif::printDebug("CCSDSDistributor::selectDestination received: %d, %d\n",
|
||||
currentMessage.getStorageId().poolIndex, currentMessage.getStorageId().packetIndex);
|
||||
#endif
|
||||
#endif
|
||||
const uint8_t* packet = nullptr;
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
|
||||
&packet, &size );
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
const uint8_t* packet = nullptr;
|
||||
size_t size = 0;
|
||||
ReturnValue_t result = this->tcStore->getData(currentMessage.getStorageId(),
|
||||
&packet, &size );
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
|
||||
" store failed!" << std::endl;
|
||||
sif::error << "CCSDSDistributor::selectDestination: Getting data from"
|
||||
" store failed!" << std::endl;
|
||||
#else
|
||||
sif::printError("CCSDSDistributor::selectDestination: Getting data from"
|
||||
sif::printError("CCSDSDistributor::selectDestination: Getting data from"
|
||||
" store failed!\n");
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
SpacePacketBase currentPacket(packet);
|
||||
}
|
||||
SpacePacketBase currentPacket(packet);
|
||||
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1 && CCSDS_DISTRIBUTOR_DEBUGGING == 1
|
||||
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex <<
|
||||
currentPacket.getAPID() << std::dec << std::endl;
|
||||
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex <<
|
||||
currentPacket.getAPID() << std::dec << std::endl;
|
||||
#endif
|
||||
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
|
||||
if ( position != this->queueMap.end() ) {
|
||||
return position;
|
||||
} else {
|
||||
//The APID was not found. Forward packet to main SW-APID anyway to
|
||||
// create acceptance failure report.
|
||||
return this->queueMap.find( this->defaultApid );
|
||||
}
|
||||
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
|
||||
if ( position != this->queueMap.end() ) {
|
||||
return position;
|
||||
} else {
|
||||
//The APID was not found. Forward packet to main SW-APID anyway to
|
||||
// create acceptance failure report.
|
||||
return this->queueMap.find( this->defaultApid );
|
||||
}
|
||||
}
|
||||
|
||||
MessageQueueId_t CCSDSDistributor::getRequestQueue() {
|
||||
return tcQueue->getId();
|
||||
return tcQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t CCSDSDistributor::registerApplication(
|
||||
AcceptsTelecommandsIF* application) {
|
||||
ReturnValue_t returnValue = RETURN_OK;
|
||||
auto insertPair = this->queueMap.emplace(application->getIdentifier(),
|
||||
application->getRequestQueue());
|
||||
if(not insertPair.second) {
|
||||
returnValue = RETURN_FAILED;
|
||||
}
|
||||
return returnValue;
|
||||
AcceptsTelecommandsIF* application) {
|
||||
ReturnValue_t returnValue = RETURN_OK;
|
||||
auto insertPair = this->queueMap.emplace(application->getIdentifier(),
|
||||
application->getRequestQueue());
|
||||
if(not insertPair.second) {
|
||||
returnValue = RETURN_FAILED;
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
ReturnValue_t CCSDSDistributor::registerApplication(uint16_t apid,
|
||||
MessageQueueId_t id) {
|
||||
ReturnValue_t returnValue = RETURN_OK;
|
||||
auto insertPair = this->queueMap.emplace(apid, id);
|
||||
if(not insertPair.second) {
|
||||
returnValue = RETURN_FAILED;
|
||||
}
|
||||
return returnValue;
|
||||
MessageQueueId_t id) {
|
||||
ReturnValue_t returnValue = RETURN_OK;
|
||||
auto insertPair = this->queueMap.emplace(apid, id);
|
||||
if(not insertPair.second) {
|
||||
returnValue = RETURN_FAILED;
|
||||
}
|
||||
return returnValue;
|
||||
|
||||
}
|
||||
|
||||
uint16_t CCSDSDistributor::getIdentifier() {
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
ReturnValue_t CCSDSDistributor::initialize() {
|
||||
ReturnValue_t status = this->TcDistributor::initialize();
|
||||
this->tcStore = ObjectManager::instance()->get<StorageManagerIF>( objects::TC_STORE );
|
||||
if (this->tcStore == nullptr) {
|
||||
ReturnValue_t status = this->TcDistributor::initialize();
|
||||
this->tcStore = ObjectManager::instance()->get<StorageManagerIF>( objects::TC_STORE );
|
||||
if (this->tcStore == nullptr) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CCSDSDistributor::initialize: Could not initialize"
|
||||
" TC store!" << std::endl;
|
||||
sif::error << "CCSDSDistributor::initialize: Could not initialize"
|
||||
" TC store!" << std::endl;
|
||||
#else
|
||||
sif::printError("CCSDSDistributor::initialize: Could not initialize"
|
||||
sif::printError("CCSDSDistributor::initialize: Could not initialize"
|
||||
" TC store!\n");
|
||||
#endif
|
||||
#endif
|
||||
status = RETURN_FAILED;
|
||||
}
|
||||
return status;
|
||||
status = RETURN_FAILED;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
ReturnValue_t CCSDSDistributor::callbackAfterSending(
|
||||
ReturnValue_t queueStatus) {
|
||||
if (queueStatus != RETURN_OK) {
|
||||
tcStore->deleteData(currentMessage.getStorageId());
|
||||
}
|
||||
return RETURN_OK;
|
||||
ReturnValue_t queueStatus) {
|
||||
if (queueStatus != RETURN_OK) {
|
||||
tcStore->deleteData(currentMessage.getStorageId());
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
@ -15,56 +15,57 @@
|
||||
* The Secondary Header (with Service/Subservice) is ignored.
|
||||
* @ingroup tc_distribution
|
||||
*/
|
||||
class CCSDSDistributor : public TcDistributor,
|
||||
public CCSDSDistributorIF,
|
||||
public AcceptsTelecommandsIF {
|
||||
class CCSDSDistributor:
|
||||
public TcDistributor,
|
||||
public CCSDSDistributorIF,
|
||||
public AcceptsTelecommandsIF {
|
||||
public:
|
||||
/**
|
||||
* @brief The constructor sets the default APID and calls the
|
||||
* TcDistributor ctor with a certain object id.
|
||||
* @details
|
||||
* @c tcStore is set in the @c initialize method.
|
||||
* @param setDefaultApid The default APID, where packets with unknown
|
||||
* destination are sent to.
|
||||
*/
|
||||
CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~CCSDSDistributor();
|
||||
/**
|
||||
* @brief The constructor sets the default APID and calls the
|
||||
* TcDistributor ctor with a certain object id.
|
||||
* @details
|
||||
* @c tcStore is set in the @c initialize method.
|
||||
* @param setDefaultApid The default APID, where packets with unknown
|
||||
* destination are sent to.
|
||||
*/
|
||||
CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~CCSDSDistributor();
|
||||
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
ReturnValue_t registerApplication( uint16_t apid,
|
||||
MessageQueueId_t id) override;
|
||||
ReturnValue_t registerApplication(
|
||||
AcceptsTelecommandsIF* application) override;
|
||||
uint16_t getIdentifier() override;
|
||||
ReturnValue_t initialize() override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
ReturnValue_t registerApplication( uint16_t apid,
|
||||
MessageQueueId_t id) override;
|
||||
ReturnValue_t registerApplication(
|
||||
AcceptsTelecommandsIF* application) override;
|
||||
uint16_t getIdentifier() override;
|
||||
ReturnValue_t initialize() override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This implementation checks if an application with fitting APID has
|
||||
* registered and forwards the packet to the according message queue.
|
||||
* If the packet is not found, it returns the queue to @c defaultApid,
|
||||
* where a Acceptance Failure message should be generated.
|
||||
* @return Iterator to map entry of found APID or iterator to default APID.
|
||||
*/
|
||||
TcMqMapIter selectDestination() override;
|
||||
/**
|
||||
* This implementation checks if an application with fitting APID has
|
||||
* registered and forwards the packet to the according message queue.
|
||||
* If the packet is not found, it returns the queue to @c defaultApid,
|
||||
* where a Acceptance Failure message should be generated.
|
||||
* @return Iterator to map entry of found APID or iterator to default APID.
|
||||
*/
|
||||
TcMqMapIter selectDestination() override;
|
||||
/**
|
||||
* The callback here handles the generation of acceptance
|
||||
* success/failure messages.
|
||||
*/
|
||||
ReturnValue_t callbackAfterSending( ReturnValue_t queueStatus ) override;
|
||||
|
||||
/**
|
||||
* The default APID, where packets with unknown APID are sent to.
|
||||
*/
|
||||
uint16_t defaultApid;
|
||||
/**
|
||||
* A reference to the TC storage must be maintained, as this class handles
|
||||
* pure Space Packets and there exists no SpacePacketStored class.
|
||||
*/
|
||||
StorageManagerIF* tcStore = nullptr;
|
||||
/**
|
||||
* The default APID, where packets with unknown APID are sent to.
|
||||
*/
|
||||
uint16_t defaultApid;
|
||||
/**
|
||||
* A reference to the TC storage must be maintained, as this class handles
|
||||
* pure Space Packets and there exists no SpacePacketStored class.
|
||||
*/
|
||||
StorageManagerIF* tcStore = nullptr;
|
||||
|
||||
};
|
||||
|
||||
|
@ -13,31 +13,30 @@
|
||||
*/
|
||||
class CCSDSDistributorIF {
|
||||
public:
|
||||
/**
|
||||
* With this call, a class implementing the CCSDSApplicationIF can register
|
||||
* at the distributor.
|
||||
* @param application A pointer to the Application to register.
|
||||
* @return - @c RETURN_OK on success,
|
||||
* - @c RETURN_FAILED on failure.
|
||||
*/
|
||||
virtual ReturnValue_t registerApplication(
|
||||
AcceptsTelecommandsIF* application) = 0;
|
||||
/**
|
||||
* With this call, other Applications can register to the CCSDS distributor.
|
||||
* This is done by passing an APID and a MessageQueueId to the method.
|
||||
* @param apid The APID to register.
|
||||
* @param id The MessageQueueId of the message queue to send the
|
||||
* TC Packets to.
|
||||
* @return - @c RETURN_OK on success,
|
||||
* - @c RETURN_FAILED on failure.
|
||||
*/
|
||||
virtual ReturnValue_t registerApplication( uint16_t apid,
|
||||
MessageQueueId_t id) = 0;
|
||||
/**
|
||||
* The empty virtual destructor.
|
||||
*/
|
||||
virtual ~CCSDSDistributorIF() {
|
||||
}
|
||||
/**
|
||||
* With this call, a class implementing the CCSDSApplicationIF can register
|
||||
* at the distributor.
|
||||
* @param application A pointer to the Application to register.
|
||||
* @return - @c RETURN_OK on success,
|
||||
* - @c RETURN_FAILED on failure.
|
||||
*/
|
||||
virtual ReturnValue_t registerApplication(
|
||||
AcceptsTelecommandsIF* application) = 0;
|
||||
/**
|
||||
* With this call, other Applications can register to the CCSDS distributor.
|
||||
* This is done by passing an APID and a MessageQueueId to the method.
|
||||
* @param apid The APID to register.
|
||||
* @param id The MessageQueueId of the message queue to send the
|
||||
* TC Packets to.
|
||||
* @return - @c RETURN_OK on success,
|
||||
* - @c RETURN_FAILED on failure.
|
||||
*/
|
||||
virtual ReturnValue_t registerApplication( uint16_t apid,
|
||||
MessageQueueId_t id) = 0;
|
||||
/**
|
||||
* The empty virtual destructor.
|
||||
*/
|
||||
virtual ~CCSDSDistributorIF() {}
|
||||
};
|
||||
|
||||
|
||||
|
147
src/fsfw/tcdistribution/CFDPDistributor.cpp
Normal file
147
src/fsfw/tcdistribution/CFDPDistributor.cpp
Normal file
@ -0,0 +1,147 @@
|
||||
#include "fsfw/tcdistribution/CCSDSDistributorIF.h"
|
||||
#include "fsfw/tcdistribution/CFDPDistributor.h"
|
||||
|
||||
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
#ifndef FSFW_CFDP_DISTRIBUTOR_DEBUGGING
|
||||
#define FSFW_CFDP_DISTRIBUTOR_DEBUGGING 1
|
||||
#endif
|
||||
|
||||
CFDPDistributor::CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||
object_id_t setPacketSource):
|
||||
TcDistributor(setObjectId), apid(setApid), checker(setApid),
|
||||
tcStatus(RETURN_FAILED), packetSource(setPacketSource) {
|
||||
}
|
||||
|
||||
CFDPDistributor::~CFDPDistributor() {}
|
||||
|
||||
CFDPDistributor::TcMqMapIter CFDPDistributor::selectDestination() {
|
||||
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
|
||||
store_address_t storeId = this->currentMessage.getStorageId();
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "CFDPDistributor::handlePacket received: " << storeId.poolIndex << ", " <<
|
||||
storeId.packetIndex << std::endl;
|
||||
#else
|
||||
sif::printDebug("CFDPDistributor::handlePacket received: %d, %d\n", storeId.poolIndex,
|
||||
storeId.packetIndex);
|
||||
#endif
|
||||
#endif
|
||||
TcMqMapIter queueMapIt = this->queueMap.end();
|
||||
if(this->currentPacket == nullptr) {
|
||||
return queueMapIt;
|
||||
}
|
||||
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
||||
if (currentPacket->getWholeData() != nullptr) {
|
||||
tcStatus = checker.checkPacket(currentPacket);
|
||||
if(tcStatus != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "CFDPDistributor::handlePacket: Packet format invalid, code " <<
|
||||
static_cast<int>(tcStatus) << std::endl;
|
||||
#else
|
||||
sif::printDebug("CFDPDistributor::handlePacket: Packet format invalid, code %d\n",
|
||||
static_cast<int>(tcStatus));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
queueMapIt = this->queueMap.find(0);
|
||||
}
|
||||
else {
|
||||
tcStatus = PACKET_LOST;
|
||||
}
|
||||
|
||||
if (queueMapIt == this->queueMap.end()) {
|
||||
tcStatus = DESTINATION_NOT_FOUND;
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::debug << "CFDPDistributor::handlePacket: Destination not found" << std::endl;
|
||||
#else
|
||||
sif::printDebug("CFDPDistributor::handlePacket: Destination not found\n");
|
||||
#endif /* !FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif
|
||||
}
|
||||
|
||||
if (tcStatus != RETURN_OK) {
|
||||
return this->queueMap.end();
|
||||
}
|
||||
else {
|
||||
return queueMapIt;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t CFDPDistributor::registerHandler(AcceptsTelecommandsIF* handler) {
|
||||
uint16_t handlerId = handler->getIdentifier(); //should be 0, because CFDPHandler does not set a set a service-ID
|
||||
#if FSFW_CFDP_DISTRIBUTOR_DEBUGGING == 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "CFDPDistributor::registerHandler: Handler ID: " << static_cast<int>(handlerId) << std::endl;
|
||||
#else
|
||||
sif::printInfo("CFDPDistributor::registerHandler: Handler ID: %d\n", static_cast<int>(handlerId));
|
||||
#endif
|
||||
#endif
|
||||
MessageQueueId_t queue = handler->getRequestQueue();
|
||||
auto returnPair = queueMap.emplace(handlerId, queue);
|
||||
if (not returnPair.second) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CFDPDistributor::registerHandler: Service ID already"
|
||||
" exists in map" << std::endl;
|
||||
#else
|
||||
sif::printError("CFDPDistributor::registerHandler: Service ID already exists in map\n");
|
||||
#endif
|
||||
#endif
|
||||
return SERVICE_ID_ALREADY_EXISTS;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
MessageQueueId_t CFDPDistributor::getRequestQueue() {
|
||||
return tcQueue->getId();
|
||||
}
|
||||
|
||||
//ReturnValue_t CFDPDistributor::callbackAfterSending(ReturnValue_t queueStatus) {
|
||||
// if (queueStatus != RETURN_OK) {
|
||||
// tcStatus = queueStatus;
|
||||
// }
|
||||
// if (tcStatus != RETURN_OK) {
|
||||
// this->verifyChannel.sendFailureReport(tc_verification::ACCEPTANCE_FAILURE,
|
||||
// currentPacket, tcStatus);
|
||||
// // A failed packet is deleted immediately after reporting,
|
||||
// // otherwise it will block memory.
|
||||
// currentPacket->deletePacket();
|
||||
// return RETURN_FAILED;
|
||||
// } else {
|
||||
// this->verifyChannel.sendSuccessReport(tc_verification::ACCEPTANCE_SUCCESS,
|
||||
// currentPacket);
|
||||
// return RETURN_OK;
|
||||
// }
|
||||
//}
|
||||
|
||||
uint16_t CFDPDistributor::getIdentifier() {
|
||||
return this->apid;
|
||||
}
|
||||
|
||||
ReturnValue_t CFDPDistributor::initialize() {
|
||||
currentPacket = new CFDPPacketStored();
|
||||
if(currentPacket == nullptr) {
|
||||
// Should not happen, memory allocation failed!
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
CCSDSDistributorIF* ccsdsDistributor = ObjectManager::instance()->get<CCSDSDistributorIF>(
|
||||
packetSource);
|
||||
if (ccsdsDistributor == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CFDPDistributor::initialize: Packet source invalid" << std::endl;
|
||||
sif::error << " Make sure it exists and implements CCSDSDistributorIF!" << std::endl;
|
||||
#else
|
||||
sif::printError("CFDPDistributor::initialize: Packet source invalid\n");
|
||||
sif::printError("Make sure it exists and implements CCSDSDistributorIF\n");
|
||||
#endif
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return ccsdsDistributor->registerApplication(this);
|
||||
}
|
72
src/fsfw/tcdistribution/CFDPDistributor.h
Normal file
72
src/fsfw/tcdistribution/CFDPDistributor.h
Normal file
@ -0,0 +1,72 @@
|
||||
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
|
||||
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_
|
||||
|
||||
#include <fsfw/tcdistribution/TcPacketCheckCFDP.h>
|
||||
#include "CFDPDistributorIF.h"
|
||||
#include "TcDistributor.h"
|
||||
#include "../tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||
#include "../tmtcservices/VerificationReporter.h"
|
||||
|
||||
/**
|
||||
* This class accepts CFDP Telecommands and forwards them to Application
|
||||
* services.
|
||||
* @ingroup tc_distribution
|
||||
*/
|
||||
class CFDPDistributor:
|
||||
public TcDistributor,
|
||||
public CFDPDistributorIF,
|
||||
public AcceptsTelecommandsIF {
|
||||
public:
|
||||
/**
|
||||
* The ctor passes @c set_apid to the checker class and calls the
|
||||
* TcDistribution ctor with a certain object id.
|
||||
* @param setApid The APID of this receiving Application.
|
||||
* @param setObjectId Object ID of the distributor itself
|
||||
* @param setPacketSource Object ID of the source of TC packets.
|
||||
* Must implement CCSDSDistributorIF.
|
||||
*/
|
||||
CFDPDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||
object_id_t setPacketSource);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~CFDPDistributor();
|
||||
ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
ReturnValue_t initialize() override;
|
||||
uint16_t getIdentifier() override;
|
||||
|
||||
protected:
|
||||
uint16_t apid;
|
||||
/**
|
||||
* The currently handled packet is stored here.
|
||||
*/
|
||||
CFDPPacketStored* currentPacket = nullptr;
|
||||
TcPacketCheckCFDP checker;
|
||||
/**
|
||||
* With this variable, the current check status is stored to generate
|
||||
* acceptance messages later.
|
||||
*/
|
||||
ReturnValue_t tcStatus;
|
||||
|
||||
const object_id_t packetSource;
|
||||
|
||||
/**
|
||||
* This method reads the packet service, checks if such a service is
|
||||
* registered and forwards the packet to the destination.
|
||||
* It also initiates the formal packet check and sending of verification
|
||||
* messages.
|
||||
* @return Iterator to map entry of found service id
|
||||
* or iterator to @c map.end().
|
||||
*/
|
||||
TcMqMapIter selectDestination() override;
|
||||
/**
|
||||
* The callback here handles the generation of acceptance
|
||||
* success/failure messages.
|
||||
*/
|
||||
//ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTOR_H_ */
|
27
src/fsfw/tcdistribution/CFDPDistributorIF.h
Normal file
27
src/fsfw/tcdistribution/CFDPDistributorIF.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_
|
||||
#define FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_
|
||||
|
||||
#include "../tmtcservices/AcceptsTelecommandsIF.h"
|
||||
#include "../ipc/MessageQueueSenderIF.h"
|
||||
|
||||
/**
|
||||
* This interface allows CFDP Services to register themselves at a CFDP Distributor.
|
||||
* @ingroup tc_distribution
|
||||
*/
|
||||
class CFDPDistributorIF {
|
||||
public:
|
||||
/**
|
||||
* The empty virtual destructor.
|
||||
*/
|
||||
virtual ~CFDPDistributorIF() {
|
||||
}
|
||||
/**
|
||||
* With this method, Handlers can register themselves at the CFDP Distributor.
|
||||
* @param handler A pointer to the registering Handler.
|
||||
* @return - @c RETURN_OK on success,
|
||||
* - @c RETURN_FAILED on failure.
|
||||
*/
|
||||
virtual ReturnValue_t registerHandler(AcceptsTelecommandsIF* handler) = 0;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TCDISTRIBUTION_CFDPDISTRIBUTORIF_H_ */
|
@ -2,5 +2,8 @@ target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
CCSDSDistributor.cpp
|
||||
PUSDistributor.cpp
|
||||
TcDistributor.cpp
|
||||
TcPacketCheck.cpp
|
||||
TcPacketCheckPUS.cpp
|
||||
TcPacketCheckCFDP.cpp
|
||||
CFDPDistributor.cpp
|
||||
)
|
||||
|
||||
|
@ -24,25 +24,25 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
||||
if(this->currentPacket == nullptr) {
|
||||
return queueMapIt;
|
||||
}
|
||||
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId());
|
||||
this->currentPacket->setStoreAddress(this->currentMessage.getStorageId(), currentPacket);
|
||||
if (currentPacket->getWholeData() != nullptr) {
|
||||
tcStatus = checker.checkPacket(currentPacket);
|
||||
if(tcStatus != HasReturnvaluesIF::RETURN_OK) {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
const char* keyword = "unnamed error";
|
||||
if(tcStatus == TcPacketCheck::INCORRECT_CHECKSUM) {
|
||||
if(tcStatus == TcPacketCheckPUS::INCORRECT_CHECKSUM) {
|
||||
keyword = "checksum";
|
||||
}
|
||||
else if(tcStatus == TcPacketCheck::INCORRECT_PRIMARY_HEADER) {
|
||||
else if(tcStatus == TcPacketCheckPUS::INCORRECT_PRIMARY_HEADER) {
|
||||
keyword = "incorrect primary header";
|
||||
}
|
||||
else if(tcStatus == TcPacketCheck::ILLEGAL_APID) {
|
||||
else if(tcStatus == TcPacketCheckPUS::ILLEGAL_APID) {
|
||||
keyword = "illegal APID";
|
||||
}
|
||||
else if(tcStatus == TcPacketCheck::INCORRECT_SECONDARY_HEADER) {
|
||||
else if(tcStatus == TcPacketCheckPUS::INCORRECT_SECONDARY_HEADER) {
|
||||
keyword = "incorrect secondary header";
|
||||
}
|
||||
else if(tcStatus == TcPacketCheck::INCOMPLETE_PACKET) {
|
||||
else if(tcStatus == TcPacketCheckPUS::INCOMPLETE_PACKET) {
|
||||
keyword = "incomplete packet";
|
||||
}
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "PUSDistributorIF.h"
|
||||
#include "TcDistributor.h"
|
||||
#include "TcPacketCheck.h"
|
||||
#include "TcPacketCheckPUS.h"
|
||||
|
||||
#include "fsfw/tmtcpacket/pus/tc.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
@ -17,65 +17,65 @@
|
||||
* @ingroup tc_distribution
|
||||
*/
|
||||
class PUSDistributor: public TcDistributor,
|
||||
public PUSDistributorIF,
|
||||
public AcceptsTelecommandsIF {
|
||||
public PUSDistributorIF,
|
||||
public AcceptsTelecommandsIF {
|
||||
public:
|
||||
/**
|
||||
* The ctor passes @c set_apid to the checker class and calls the
|
||||
* TcDistribution ctor with a certain object id.
|
||||
* @param setApid The APID of this receiving Application.
|
||||
* @param setObjectId Object ID of the distributor itself
|
||||
* @param setPacketSource Object ID of the source of TC packets.
|
||||
* Must implement CCSDSDistributorIF.
|
||||
*/
|
||||
PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||
object_id_t setPacketSource);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~PUSDistributor();
|
||||
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
ReturnValue_t initialize() override;
|
||||
uint16_t getIdentifier() override;
|
||||
/**
|
||||
* The ctor passes @c set_apid to the checker class and calls the
|
||||
* TcDistribution ctor with a certain object id.
|
||||
* @param setApid The APID of this receiving Application.
|
||||
* @param setObjectId Object ID of the distributor itself
|
||||
* @param setPacketSource Object ID of the source of TC packets.
|
||||
* Must implement CCSDSDistributorIF.
|
||||
*/
|
||||
PUSDistributor(uint16_t setApid, object_id_t setObjectId,
|
||||
object_id_t setPacketSource);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~PUSDistributor();
|
||||
ReturnValue_t registerService(AcceptsTelecommandsIF* service) override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
ReturnValue_t initialize() override;
|
||||
uint16_t getIdentifier() override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* This attribute contains the class, that performs a formal packet check.
|
||||
*/
|
||||
TcPacketCheck checker;
|
||||
/**
|
||||
* With this class, verification messages are sent to the
|
||||
* TC Verification service.
|
||||
*/
|
||||
VerificationReporter verifyChannel;
|
||||
/**
|
||||
* The currently handled packet is stored here.
|
||||
*/
|
||||
TcPacketStoredPus* currentPacket = nullptr;
|
||||
/**
|
||||
* This attribute contains the class, that performs a formal packet check.
|
||||
*/
|
||||
TcPacketCheckPUS checker;
|
||||
/**
|
||||
* With this class, verification messages are sent to the
|
||||
* TC Verification service.
|
||||
*/
|
||||
VerificationReporter verifyChannel;
|
||||
/**
|
||||
* The currently handled packet is stored here.
|
||||
*/
|
||||
TcPacketStoredPus* currentPacket = nullptr;
|
||||
|
||||
/**
|
||||
* With this variable, the current check status is stored to generate
|
||||
* acceptance messages later.
|
||||
*/
|
||||
ReturnValue_t tcStatus;
|
||||
/**
|
||||
* With this variable, the current check status is stored to generate
|
||||
* acceptance messages later.
|
||||
*/
|
||||
ReturnValue_t tcStatus;
|
||||
|
||||
const object_id_t packetSource;
|
||||
const object_id_t packetSource;
|
||||
|
||||
/**
|
||||
* This method reads the packet service, checks if such a service is
|
||||
* registered and forwards the packet to the destination.
|
||||
* It also initiates the formal packet check and sending of verification
|
||||
* messages.
|
||||
* @return Iterator to map entry of found service id
|
||||
* or iterator to @c map.end().
|
||||
*/
|
||||
TcMqMapIter selectDestination() override;
|
||||
/**
|
||||
* The callback here handles the generation of acceptance
|
||||
* success/failure messages.
|
||||
*/
|
||||
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
||||
/**
|
||||
* This method reads the packet service, checks if such a service is
|
||||
* registered and forwards the packet to the destination.
|
||||
* It also initiates the formal packet check and sending of verification
|
||||
* messages.
|
||||
* @return Iterator to map entry of found service id
|
||||
* or iterator to @c map.end().
|
||||
*/
|
||||
TcMqMapIter selectDestination() override;
|
||||
/**
|
||||
* The callback here handles the generation of acceptance
|
||||
* success/failure messages.
|
||||
*/
|
||||
ReturnValue_t callbackAfterSending(ReturnValue_t queueStatus) override;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTOR_H_ */
|
||||
|
@ -10,18 +10,18 @@
|
||||
*/
|
||||
class PUSDistributorIF {
|
||||
public:
|
||||
/**
|
||||
* The empty virtual destructor.
|
||||
*/
|
||||
virtual ~PUSDistributorIF() {
|
||||
}
|
||||
/**
|
||||
* With this method, Services can register themselves at the PUS Distributor.
|
||||
* @param service A pointer to the registering Service.
|
||||
* @return - @c RETURN_OK on success,
|
||||
* - @c RETURN_FAILED on failure.
|
||||
*/
|
||||
virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0;
|
||||
/**
|
||||
* The empty virtual destructor.
|
||||
*/
|
||||
virtual ~PUSDistributorIF() {
|
||||
}
|
||||
/**
|
||||
* With this method, Services can register themselves at the PUS Distributor.
|
||||
* @param service A pointer to the registering Service.
|
||||
* @return - @c RETURN_OK on success,
|
||||
* - @c RETURN_FAILED on failure.
|
||||
*/
|
||||
virtual ReturnValue_t registerService( AcceptsTelecommandsIF* service ) = 0;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TCDISTRIBUTION_PUSDISTRIBUTORIF_H_ */
|
||||
|
13
src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp
Normal file
13
src/fsfw/tcdistribution/TcPacketCheckCFDP.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include "fsfw/tcdistribution/TcPacketCheckCFDP.h"
|
||||
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||
|
||||
TcPacketCheckCFDP::TcPacketCheckCFDP(uint16_t setApid): apid(setApid) {
|
||||
}
|
||||
|
||||
ReturnValue_t TcPacketCheckCFDP::checkPacket(SpacePacketBase* currentPacket) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
uint16_t TcPacketCheckCFDP::getApid() const {
|
||||
return apid;
|
||||
}
|
35
src/fsfw/tcdistribution/TcPacketCheckCFDP.h
Normal file
35
src/fsfw/tcdistribution/TcPacketCheckCFDP.h
Normal file
@ -0,0 +1,35 @@
|
||||
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_
|
||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_
|
||||
|
||||
#include "TcPacketCheckIF.h"
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
|
||||
class CFDPPacketStored;
|
||||
|
||||
/**
|
||||
* This class performs a formal packet check for incoming CFDP Packets.
|
||||
* @ingroup tc_distribution
|
||||
*/
|
||||
class TcPacketCheckCFDP :
|
||||
public TcPacketCheckIF,
|
||||
public HasReturnvaluesIF {
|
||||
protected:
|
||||
/**
|
||||
* The packet id each correct packet should have.
|
||||
* It is composed of the APID and some static fields.
|
||||
*/
|
||||
uint16_t apid;
|
||||
public:
|
||||
/**
|
||||
* The constructor only sets the APID attribute.
|
||||
* @param set_apid The APID to set.
|
||||
*/
|
||||
TcPacketCheckCFDP(uint16_t setApid);
|
||||
|
||||
ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override;
|
||||
|
||||
uint16_t getApid() const;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKCFDP_H_ */
|
31
src/fsfw/tcdistribution/TcPacketCheckIF.h
Normal file
31
src/fsfw/tcdistribution/TcPacketCheckIF.h
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
|
||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_
|
||||
|
||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class SpacePacketBase;
|
||||
|
||||
/**
|
||||
* This interface is used by PacketCheckers for PUS packets and CFDP packets .
|
||||
* @ingroup tc_distribution
|
||||
*/
|
||||
class TcPacketCheckIF {
|
||||
public:
|
||||
/**
|
||||
* The empty virtual destructor.
|
||||
*/
|
||||
virtual ~TcPacketCheckIF() {
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the actual method to formally check a certain Packet.
|
||||
* The packet's Application Data can not be checked here.
|
||||
* @param current_packet The packet to check
|
||||
* @return - @c RETURN_OK on success.
|
||||
* - @c INCORRECT_CHECKSUM if checksum is invalid.
|
||||
* - @c ILLEGAL_APID if APID does not match.
|
||||
*/
|
||||
virtual ReturnValue_t checkPacket(SpacePacketBase* currentPacket) = 0;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKIF_H_ */
|
@ -1,18 +1,20 @@
|
||||
#include "fsfw/tcdistribution/TcPacketCheck.h"
|
||||
#include "fsfw/tcdistribution/TcPacketCheckPUS.h"
|
||||
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredPus.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
#include "fsfw/tmtcservices/VerificationCodes.h"
|
||||
|
||||
TcPacketCheck::TcPacketCheck(uint16_t setApid): apid(setApid) {
|
||||
TcPacketCheckPUS::TcPacketCheckPUS(uint16_t setApid): apid(setApid) {
|
||||
}
|
||||
|
||||
ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
|
||||
TcPacketBase* tcPacketBase = currentPacket->getPacketBase();
|
||||
if(tcPacketBase == nullptr) {
|
||||
ReturnValue_t TcPacketCheckPUS::checkPacket(SpacePacketBase* currentPacket) {
|
||||
TcPacketStoredBase* storedPacket = dynamic_cast<TcPacketStoredBase*>(currentPacket);
|
||||
TcPacketPusBase* tcPacketBase = dynamic_cast<TcPacketPusBase*>(currentPacket);
|
||||
if(tcPacketBase == nullptr or storedPacket == nullptr) {
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
uint16_t calculated_crc = CRC::crc16ccitt(tcPacketBase->getWholeData(),
|
||||
@ -29,7 +31,7 @@ ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
|
||||
if (tcPacketBase->getAPID() != this->apid)
|
||||
return ILLEGAL_APID;
|
||||
|
||||
if (not currentPacket->isSizeCorrect()) {
|
||||
if (not storedPacket->isSizeCorrect()) {
|
||||
return INCOMPLETE_PACKET;
|
||||
}
|
||||
|
||||
@ -41,6 +43,6 @@ ReturnValue_t TcPacketCheck::checkPacket(TcPacketStoredBase* currentPacket) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
uint16_t TcPacketCheck::getApid() const {
|
||||
uint16_t TcPacketCheckPUS::getApid() const {
|
||||
return apid;
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_
|
||||
#ifndef FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
|
||||
#define FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_
|
||||
|
||||
#include "TcPacketCheckIF.h"
|
||||
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
@ -12,7 +14,9 @@ class TcPacketStoredBase;
|
||||
* Currently, it only checks if the APID and CRC are correct.
|
||||
* @ingroup tc_distribution
|
||||
*/
|
||||
class TcPacketCheck : public HasReturnvaluesIF {
|
||||
class TcPacketCheckPUS :
|
||||
public TcPacketCheckIF,
|
||||
public HasReturnvaluesIF {
|
||||
protected:
|
||||
/**
|
||||
* Describes the version number a packet must have to pass.
|
||||
@ -49,18 +53,11 @@ public:
|
||||
* The constructor only sets the APID attribute.
|
||||
* @param set_apid The APID to set.
|
||||
*/
|
||||
TcPacketCheck(uint16_t setApid);
|
||||
/**
|
||||
* This is the actual method to formally check a certain Telecommand Packet.
|
||||
* The packet's Application Data can not be checked here.
|
||||
* @param current_packet The packt to check
|
||||
* @return - @c RETURN_OK on success.
|
||||
* - @c INCORRECT_CHECKSUM if checksum is invalid.
|
||||
* - @c ILLEGAL_APID if APID does not match.
|
||||
*/
|
||||
ReturnValue_t checkPacket(TcPacketStoredBase* currentPacket);
|
||||
TcPacketCheckPUS(uint16_t setApid);
|
||||
|
||||
ReturnValue_t checkPacket(SpacePacketBase* currentPacket) override;
|
||||
|
||||
uint16_t getApid() const;
|
||||
};
|
||||
|
||||
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECK_H_ */
|
||||
#endif /* FSFW_TCDISTRIBUTION_TCPACKETCHECKPUS_H_ */
|
@ -3,5 +3,6 @@ target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
SpacePacketBase.cpp
|
||||
)
|
||||
|
||||
add_subdirectory(cfdp)
|
||||
add_subdirectory(packetmatcher)
|
||||
add_subdirectory(pus)
|
25
src/fsfw/tmtcpacket/RedirectableDataPointerIF.h
Normal file
25
src/fsfw/tmtcpacket/RedirectableDataPointerIF.h
Normal file
@ -0,0 +1,25 @@
|
||||
#ifndef TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_
|
||||
#define TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_
|
||||
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
/**
|
||||
* @brief This interface can be used for classes which store a reference to data. It allows
|
||||
* the implementing class to redirect the data it refers too.
|
||||
*/
|
||||
class RedirectableDataPointerIF {
|
||||
public:
|
||||
virtual ~RedirectableDataPointerIF() {};
|
||||
|
||||
/**
|
||||
* Redirect the data pointer.
|
||||
* @param dataPtr
|
||||
* @return
|
||||
*/
|
||||
virtual ReturnValue_t setData(const uint8_t* dataPtr) = 0;
|
||||
private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_SRC_FSFW_TMTCPACKET_PUS_TC_SETTABLEDATAPOINTERIF_H_ */
|
@ -5,23 +5,23 @@
|
||||
SpacePacket::SpacePacket(uint16_t packetDataLength, bool isTelecommand, uint16_t apid,
|
||||
uint16_t sequenceCount):
|
||||
SpacePacketBase( (uint8_t*)&this->localData ) {
|
||||
initSpacePacketHeader(isTelecommand, false, apid, sequenceCount);
|
||||
this->setPacketSequenceCount(sequenceCount);
|
||||
if ( packetDataLength <= sizeof(this->localData.fields.buffer) ) {
|
||||
this->setPacketDataLength(packetDataLength);
|
||||
} else {
|
||||
this->setPacketDataLength( sizeof(this->localData.fields.buffer) );
|
||||
}
|
||||
initSpacePacketHeader(isTelecommand, false, apid, sequenceCount);
|
||||
this->setPacketSequenceCount(sequenceCount);
|
||||
if ( packetDataLength <= sizeof(this->localData.fields.buffer) ) {
|
||||
this->setPacketDataLength(packetDataLength);
|
||||
} else {
|
||||
this->setPacketDataLength( sizeof(this->localData.fields.buffer) );
|
||||
}
|
||||
}
|
||||
|
||||
SpacePacket::~SpacePacket( void ) {
|
||||
}
|
||||
|
||||
bool SpacePacket::addWholeData( const uint8_t* p_Data, uint32_t packet_size ) {
|
||||
if ( packet_size <= sizeof(this->data) ) {
|
||||
memcpy( &this->localData.byteStream, p_Data, packet_size );
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
if ( packet_size <= sizeof(this->data) ) {
|
||||
memcpy( &this->localData.byteStream, p_Data, packet_size );
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
* @param sequenceCount ets the packet's Source Sequence Count field.
|
||||
*/
|
||||
SpacePacket(uint16_t packetDataLength, bool isTelecommand = false,
|
||||
uint16_t apid = APID_IDLE_PACKET, uint16_t sequenceCount = 0);
|
||||
uint16_t apid = APID_IDLE_PACKET, uint16_t sequenceCount = 0);
|
||||
/**
|
||||
* The class's default destructor.
|
||||
*/
|
||||
|
@ -110,8 +110,9 @@ uint8_t* SpacePacketBase::getWholeData() {
|
||||
return (uint8_t*)this->data;
|
||||
}
|
||||
|
||||
void SpacePacketBase::setData( const uint8_t* p_Data ) {
|
||||
ReturnValue_t SpacePacketBase::setData( const uint8_t* p_Data ) {
|
||||
this->data = (SpacePacketPointer*)p_Data;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint32_t SpacePacketBase::getApidAndSequenceCount() const {
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef FSFW_TMTCPACKET_SPACEPACKETBASE_H_
|
||||
#define FSFW_TMTCPACKET_SPACEPACKETBASE_H_
|
||||
|
||||
#include <fsfw/tmtcpacket/RedirectableDataPointerIF.h>
|
||||
#include "ccsds_header.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
@ -37,7 +38,7 @@ struct SpacePacketPointer {
|
||||
* the most significant bit (from left).
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class SpacePacketBase {
|
||||
class SpacePacketBase: virtual public RedirectableDataPointerIF {
|
||||
protected:
|
||||
/**
|
||||
* A pointer to a structure which defines the data structure of
|
||||
@ -70,8 +71,7 @@ public:
|
||||
*/
|
||||
virtual ~SpacePacketBase();
|
||||
|
||||
//CCSDS Methods
|
||||
|
||||
//CCSDS Methods:
|
||||
/**
|
||||
* Getter for the packet version number field.
|
||||
* @return Returns the highest three bit of the packet in one byte.
|
||||
@ -163,7 +163,7 @@ public:
|
||||
*/
|
||||
void setPacketDataLength( uint16_t setLength );
|
||||
|
||||
// Helper methods
|
||||
//Helper methods:
|
||||
/**
|
||||
* This method returns a raw uint8_t pointer to the packet.
|
||||
* @return A \c uint8_t pointer to the first byte of the CCSDS primary header.
|
||||
@ -176,7 +176,7 @@ public:
|
||||
* location.
|
||||
* @param p_Data A pointer to another raw Space Packet.
|
||||
*/
|
||||
virtual void setData( const uint8_t* p_Data );
|
||||
virtual ReturnValue_t setData( const uint8_t* p_Data ) override;
|
||||
/**
|
||||
* This method returns the full raw packet size.
|
||||
* @return The full size of the packet in bytes.
|
||||
|
20
src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp
Normal file
20
src/fsfw/tmtcpacket/cfdp/CFDPPacket.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "fsfw/tmtcpacket/cfdp/CFDPPacket.h"
|
||||
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
CFDPPacket::CFDPPacket(const uint8_t* setData): SpacePacketBase(setData) {}
|
||||
|
||||
CFDPPacket::~CFDPPacket() {}
|
||||
|
||||
void CFDPPacket::print() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "CFDPPacket::print:" << std::endl;
|
||||
#else
|
||||
sif::printInfo("CFDPPacket::print:\n");
|
||||
#endif
|
||||
arrayprinter::print(getWholeData(), getFullSize());
|
||||
}
|
27
src/fsfw/tmtcpacket/cfdp/CFDPPacket.h
Normal file
27
src/fsfw/tmtcpacket/cfdp/CFDPPacket.h
Normal file
@ -0,0 +1,27 @@
|
||||
#ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_
|
||||
#define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_
|
||||
|
||||
#include "fsfw/tmtcpacket/SpacePacketBase.h"
|
||||
|
||||
class CFDPPacket : public SpacePacketBase {
|
||||
public:
|
||||
/**
|
||||
* This is the default constructor.
|
||||
* It sets its internal data pointer to the address passed and also
|
||||
* forwards the data pointer to the parent SpacePacketBase class.
|
||||
* @param setData The position where the packet data lies.
|
||||
*/
|
||||
CFDPPacket( const uint8_t* setData );
|
||||
/**
|
||||
* This is the empty default destructor.
|
||||
*/
|
||||
virtual ~CFDPPacket();
|
||||
|
||||
/**
|
||||
* This is a debugging helper method that prints the whole packet content
|
||||
* to the screen.
|
||||
*/
|
||||
void print();
|
||||
};
|
||||
|
||||
#endif /* FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKET_H_ */
|
96
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp
Normal file
96
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include "fsfw/tmtcpacket/cfdp/CFDPPacketStored.h"
|
||||
#include "fsfw/objectmanager/ObjectManager.h"
|
||||
|
||||
StorageManagerIF* CFDPPacketStored::store = nullptr;
|
||||
|
||||
CFDPPacketStored::CFDPPacketStored(): CFDPPacket(nullptr) {
|
||||
}
|
||||
|
||||
CFDPPacketStored::CFDPPacketStored(store_address_t setAddress): CFDPPacket(nullptr) {
|
||||
this->setStoreAddress(setAddress);
|
||||
}
|
||||
|
||||
CFDPPacketStored::CFDPPacketStored(const uint8_t* data, size_t size): CFDPPacket(data) {
|
||||
if (this->getFullSize() != size) {
|
||||
return;
|
||||
}
|
||||
if (this->checkAndSetStore()) {
|
||||
ReturnValue_t status = store->addData(&storeAddress, data, size);
|
||||
if (status != HasReturnvaluesIF::RETURN_OK) {
|
||||
this->setData(nullptr);
|
||||
}
|
||||
const uint8_t* storePtr = nullptr;
|
||||
// Repoint base data pointer to the data in the store.
|
||||
store->getData(storeAddress, &storePtr, &size);
|
||||
this->setData(storePtr);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t CFDPPacketStored::deletePacket() {
|
||||
ReturnValue_t result = this->store->deleteData(this->storeAddress);
|
||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
this->setData(nullptr);
|
||||
return result;
|
||||
}
|
||||
|
||||
//CFDPPacket* CFDPPacketStored::getPacketBase() {
|
||||
// return this;
|
||||
//}
|
||||
void CFDPPacketStored::setStoreAddress(store_address_t setAddress) {
|
||||
this->storeAddress = setAddress;
|
||||
const uint8_t* tempData = nullptr;
|
||||
size_t tempSize;
|
||||
ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
|
||||
if (this->checkAndSetStore()) {
|
||||
status = this->store->getData(this->storeAddress, &tempData, &tempSize);
|
||||
}
|
||||
if (status == StorageManagerIF::RETURN_OK) {
|
||||
this->setData(tempData);
|
||||
}
|
||||
else {
|
||||
this->setData(nullptr);
|
||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
}
|
||||
}
|
||||
|
||||
store_address_t CFDPPacketStored::getStoreAddress() {
|
||||
return this->storeAddress;
|
||||
}
|
||||
|
||||
CFDPPacketStored::~CFDPPacketStored() {
|
||||
}
|
||||
|
||||
ReturnValue_t CFDPPacketStored::getData(const uint8_t **dataPtr, size_t *dataSize) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
//ReturnValue_t CFDPPacketStored::setData(const uint8_t *data) {
|
||||
// return HasReturnvaluesIF::RETURN_OK;
|
||||
//}
|
||||
|
||||
bool CFDPPacketStored::checkAndSetStore() {
|
||||
if (this->store == nullptr) {
|
||||
this->store = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||
if (this->store == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CFDPPacketStored::CFDPPacketStored: TC Store not found!"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CFDPPacketStored::isSizeCorrect() {
|
||||
const uint8_t* temp_data = nullptr;
|
||||
size_t temp_size;
|
||||
ReturnValue_t status = this->store->getData(this->storeAddress, &temp_data,
|
||||
&temp_size);
|
||||
if (status == StorageManagerIF::RETURN_OK) {
|
||||
if (this->getFullSize() == temp_size) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
67
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h
Normal file
67
src/fsfw/tmtcpacket/cfdp/CFDPPacketStored.h
Normal file
@ -0,0 +1,67 @@
|
||||
#ifndef FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
|
||||
#define FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
|
||||
|
||||
#include "../pus/tc/TcPacketStoredBase.h"
|
||||
#include "CFDPPacket.h"
|
||||
|
||||
class CFDPPacketStored:
|
||||
public CFDPPacket,
|
||||
public TcPacketStoredBase {
|
||||
public:
|
||||
/**
|
||||
* Create stored packet with existing data.
|
||||
* @param data
|
||||
* @param size
|
||||
*/
|
||||
CFDPPacketStored(const uint8_t* data, size_t size);
|
||||
/**
|
||||
* Create stored packet from existing packet in store
|
||||
* @param setAddress
|
||||
*/
|
||||
CFDPPacketStored(store_address_t setAddress);
|
||||
CFDPPacketStored();
|
||||
|
||||
virtual ~CFDPPacketStored();
|
||||
|
||||
/**
|
||||
* Getter function for the raw data.
|
||||
* @param dataPtr [out] Pointer to the data pointer to set
|
||||
* @param dataSize [out] Address of size to set.
|
||||
* @return -@c RETURN_OK if data was retrieved successfully.
|
||||
*/
|
||||
ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize);
|
||||
|
||||
void setStoreAddress(store_address_t setAddress);
|
||||
|
||||
store_address_t getStoreAddress();
|
||||
|
||||
ReturnValue_t deletePacket();
|
||||
|
||||
private:
|
||||
|
||||
bool isSizeCorrect();
|
||||
protected:
|
||||
/**
|
||||
* This is a pointer to the store all instances of the class use.
|
||||
* If the store is not yet set (i.e. @c store is NULL), every constructor
|
||||
* call tries to set it and throws an error message in case of failures.
|
||||
* The default store is objects::TC_STORE.
|
||||
*/
|
||||
static StorageManagerIF* store;
|
||||
/**
|
||||
* The address where the packet data of the object instance is stored.
|
||||
*/
|
||||
store_address_t storeAddress;
|
||||
/**
|
||||
* A helper method to check if a store is assigned to the class.
|
||||
* If not, the method tries to retrieve the store from the global
|
||||
* ObjectManager.
|
||||
* @return @li @c true if the store is linked or could be created.
|
||||
* @li @c false otherwise.
|
||||
*/
|
||||
bool checkAndSetStore();
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FSFW_INC_FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_ */
|
4
src/fsfw/tmtcpacket/cfdp/CMakeLists.txt
Normal file
4
src/fsfw/tmtcpacket/cfdp/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
CFDPPacket.cpp
|
||||
CFDPPacketStored.cpp
|
||||
)
|
@ -1,5 +1,5 @@
|
||||
target_sources(${LIB_FSFW_NAME} PRIVATE
|
||||
TcPacketBase.cpp
|
||||
TcPacketPusBase.cpp
|
||||
TcPacketPus.cpp
|
||||
TcPacketStoredBase.cpp
|
||||
TcPacketStoredPus.cpp
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
TcPacketPus::TcPacketPus(const uint8_t *setData): TcPacketBase(setData) {
|
||||
TcPacketPus::TcPacketPus(const uint8_t *setData): TcPacketPusBase(setData) {
|
||||
tcData = reinterpret_cast<TcPacketPointer*>(const_cast<uint8_t*>(setData));
|
||||
}
|
||||
|
||||
@ -59,11 +59,12 @@ void TcPacketPus::setErrorControl() {
|
||||
(&tcData->appData)[size + 1] = (crc) & 0X00FF; // CRCL
|
||||
}
|
||||
|
||||
void TcPacketPus::setData(const uint8_t* pData) {
|
||||
ReturnValue_t TcPacketPus::setData(const uint8_t* pData) {
|
||||
SpacePacketBase::setData(pData);
|
||||
// This function is const-correct, but it was decided to keep the pointer non-const
|
||||
// for convenience. Therefore, cast aways constness here and then cast to packet type.
|
||||
// for convenience. Therefore, cast away constness here and then cast to packet type.
|
||||
tcData = reinterpret_cast<TcPacketPointer*>(const_cast<uint8_t*>(pData));
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
uint8_t TcPacketPus::getSecondaryHeaderFlag() const {
|
||||
@ -93,5 +94,5 @@ uint16_t TcPacketPus::getSourceId() const {
|
||||
|
||||
size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const {
|
||||
return sizeof(CCSDSPrimaryHeader) + sizeof(PUSTcDataFieldHeader) +
|
||||
appDataLen + TcPacketBase::CRC_SIZE;
|
||||
appDataLen + TcPacketPusBase::CRC_SIZE;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "fsfw/FSFW.h"
|
||||
#include "../definitions.h"
|
||||
#include "fsfw/tmtcpacket/ccsds_header.h"
|
||||
#include "TcPacketBase.h"
|
||||
#include "TcPacketPusBase.h"
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@ -38,7 +38,7 @@ struct TcPacketPointer {
|
||||
};
|
||||
|
||||
|
||||
class TcPacketPus: public TcPacketBase {
|
||||
class TcPacketPus: public TcPacketPusBase {
|
||||
public:
|
||||
static const uint16_t TC_PACKET_MIN_SIZE = (sizeof(CCSDSPrimaryHeader) +
|
||||
sizeof(PUSTcDataFieldHeader) + 2);
|
||||
@ -65,7 +65,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
void setData(const uint8_t* pData) override;
|
||||
ReturnValue_t setData(const uint8_t* dataPtr) override;
|
||||
|
||||
/**
|
||||
* Initializes the Tc Packet header.
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h"
|
||||
#include "TcPacketPusBase.h"
|
||||
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include "fsfw/globalfunctions/arrayprinter.h"
|
||||
@ -6,11 +6,11 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
TcPacketBase::TcPacketBase(const uint8_t* setData): SpacePacketBase(setData) {}
|
||||
TcPacketPusBase::TcPacketPusBase(const uint8_t* setData): SpacePacketBase(setData) {}
|
||||
|
||||
TcPacketBase::~TcPacketBase() {}
|
||||
TcPacketPusBase::~TcPacketPusBase() {}
|
||||
|
||||
void TcPacketBase::print() {
|
||||
void TcPacketPusBase::print() {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::info << "TcPacketBase::print:" << std::endl;
|
||||
#else
|
@ -1,6 +1,7 @@
|
||||
#ifndef TMTCPACKET_PUS_TCPACKETBASE_H_
|
||||
#define TMTCPACKET_PUS_TCPACKETBASE_H_
|
||||
|
||||
#include <fsfw/tmtcpacket/RedirectableDataPointerIF.h>
|
||||
#include "fsfw/tmtcpacket/SpacePacketBase.h"
|
||||
#include <cstddef>
|
||||
|
||||
@ -15,7 +16,8 @@
|
||||
* check can be performed by making use of the getWholeData method.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TcPacketBase : public SpacePacketBase {
|
||||
class TcPacketPusBase : public SpacePacketBase,
|
||||
virtual public RedirectableDataPointerIF {
|
||||
|
||||
friend class TcPacketStoredBase;
|
||||
public:
|
||||
|
||||
@ -41,11 +43,11 @@ public:
|
||||
* forwards the data pointer to the parent SpacePacketBase class.
|
||||
* @param setData The position where the packet data lies.
|
||||
*/
|
||||
TcPacketBase( const uint8_t* setData );
|
||||
TcPacketPusBase( const uint8_t* setData );
|
||||
/**
|
||||
* This is the empty default destructor.
|
||||
*/
|
||||
virtual ~TcPacketBase();
|
||||
virtual ~TcPacketPusBase();
|
||||
|
||||
/**
|
||||
* This command returns the CCSDS Secondary Header Flag.
|
||||
@ -133,6 +135,7 @@ public:
|
||||
* to the screen.
|
||||
*/
|
||||
void print();
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
@ -143,7 +146,7 @@ protected:
|
||||
*
|
||||
* @param p_data A pointer to another PUS Telecommand Packet.
|
||||
*/
|
||||
void setData( const uint8_t* pData ) = 0;
|
||||
virtual ReturnValue_t setData( const uint8_t* pData ) = 0;
|
||||
};
|
||||
|
||||
|
@ -46,7 +46,8 @@ bool TcPacketStoredBase::checkAndSetStore() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void TcPacketStoredBase::setStoreAddress(store_address_t setAddress) {
|
||||
void TcPacketStoredBase::setStoreAddress(store_address_t setAddress,
|
||||
RedirectableDataPointerIF* packet) {
|
||||
this->storeAddress = setAddress;
|
||||
const uint8_t* tempData = nullptr;
|
||||
size_t tempSize;
|
||||
@ -54,15 +55,12 @@ void TcPacketStoredBase::setStoreAddress(store_address_t setAddress) {
|
||||
if (this->checkAndSetStore()) {
|
||||
status = this->store->getData(this->storeAddress, &tempData, &tempSize);
|
||||
}
|
||||
TcPacketBase* tcPacketBase = this->getPacketBase();
|
||||
if(tcPacketBase == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (status == StorageManagerIF::RETURN_OK) {
|
||||
tcPacketBase->setData(tempData);
|
||||
packet->setData(tempData);
|
||||
}
|
||||
else {
|
||||
tcPacketBase->setData(nullptr);
|
||||
packet->setData(nullptr);
|
||||
this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,10 @@
|
||||
#define TMTCPACKET_PUS_TCPACKETSTORED_H_
|
||||
|
||||
#include "TcPacketStoredIF.h"
|
||||
#include "../../../storagemanager/StorageManagerIF.h"
|
||||
#include "fsfw/storagemanager/StorageManagerIF.h"
|
||||
|
||||
/**
|
||||
* This class generates a ECSS PUS Telecommand packet within a given
|
||||
* intermediate storage.
|
||||
* As most packets are passed between tasks with the help of a storage
|
||||
* anyway, it seems logical to create a Packet-In-Storage access class
|
||||
* which saves the user almost all storage handling operation.
|
||||
* Packets can both be newly created with the class and be "linked" to
|
||||
* packets in a store with the help of a storeAddress.
|
||||
* Base class for telecommand packets like CFDP or PUS packets.
|
||||
* @ingroup tmtcpackets
|
||||
*/
|
||||
class TcPacketStoredBase: public TcPacketStoredIF {
|
||||
@ -44,7 +38,7 @@ public:
|
||||
*/
|
||||
ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize) override;
|
||||
|
||||
void setStoreAddress(store_address_t setAddress) override;
|
||||
void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) override;
|
||||
store_address_t getStoreAddress() override;
|
||||
|
||||
/**
|
||||
|
@ -1,9 +1,10 @@
|
||||
#ifndef FSFW_TMTCPACKET_PUS_TCPACKETSTOREDIF_H_
|
||||
#define FSFW_TMTCPACKET_PUS_TCPACKETSTOREDIF_H_
|
||||
|
||||
#include "TcPacketBase.h"
|
||||
#include "../../../storagemanager/storeAddress.h"
|
||||
#include "../../../returnvalues/HasReturnvaluesIF.h"
|
||||
#include <fsfw/tmtcpacket/RedirectableDataPointerIF.h>
|
||||
#include "TcPacketPusBase.h"
|
||||
#include "fsfw/storagemanager/storeAddress.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class TcPacketStoredIF {
|
||||
public:
|
||||
@ -14,7 +15,7 @@ public:
|
||||
* if the packet is a class member and used for more than one packet.
|
||||
* @param setAddress The new packet id to link to.
|
||||
*/
|
||||
virtual void setStoreAddress(store_address_t setAddress) = 0;
|
||||
virtual void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) = 0;
|
||||
|
||||
virtual store_address_t getStoreAddress() = 0;
|
||||
|
||||
@ -25,12 +26,6 @@ public:
|
||||
* @return -@c RETURN_OK if data was retrieved successfully.
|
||||
*/
|
||||
virtual ReturnValue_t getData(const uint8_t ** dataPtr, size_t* dataSize) = 0;
|
||||
|
||||
/**
|
||||
* Get packet base pointer which can be used to get access to PUS packet fields
|
||||
* @return
|
||||
*/
|
||||
virtual TcPacketBase* getPacketBase() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ TcPacketStoredPus::TcPacketStoredPus(): TcPacketStoredBase(), TcPacketPus(nullpt
|
||||
}
|
||||
|
||||
TcPacketStoredPus::TcPacketStoredPus(store_address_t setAddress): TcPacketPus(nullptr) {
|
||||
TcPacketStoredBase::setStoreAddress(setAddress);
|
||||
TcPacketStoredBase::setStoreAddress(setAddress, this);
|
||||
}
|
||||
|
||||
TcPacketStoredPus::TcPacketStoredPus(const uint8_t* data, size_t size): TcPacketPus(data) {
|
||||
@ -65,7 +65,7 @@ ReturnValue_t TcPacketStoredPus::deletePacket() {
|
||||
return result;
|
||||
}
|
||||
|
||||
TcPacketBase* TcPacketStoredPus::getPacketBase() {
|
||||
TcPacketPusBase* TcPacketStoredPus::getPacketBase() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
*/
|
||||
TcPacketStoredPus(uint16_t apid, uint8_t service, uint8_t subservice,
|
||||
uint8_t sequence_count = 0, const uint8_t* data = nullptr,
|
||||
size_t size = 0, uint8_t ack = TcPacketBase::ACK_ALL);
|
||||
size_t size = 0, uint8_t ack = TcPacketPusBase::ACK_ALL);
|
||||
/**
|
||||
* Create stored packet with existing data.
|
||||
* @param data
|
||||
@ -41,7 +41,7 @@ public:
|
||||
TcPacketStoredPus();
|
||||
|
||||
ReturnValue_t deletePacket() override;
|
||||
TcPacketBase* getPacketBase() override;
|
||||
TcPacketPusBase* getPacketBase();
|
||||
|
||||
private:
|
||||
|
||||
|
@ -36,9 +36,10 @@ uint16_t TmPacketPusA::getSourceDataSize() {
|
||||
- CRC_SIZE + 1;
|
||||
}
|
||||
|
||||
void TmPacketPusA::setData(const uint8_t* p_Data) {
|
||||
ReturnValue_t TmPacketPusA::setData(const uint8_t* p_Data) {
|
||||
SpacePacketBase::setData(p_Data);
|
||||
tmData = (TmPacketPointerPusA*) p_Data;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,7 +110,7 @@ protected:
|
||||
*
|
||||
* @param p_data A pointer to another PUS Telemetry Packet.
|
||||
*/
|
||||
void setData( const uint8_t* pData );
|
||||
ReturnValue_t setData( const uint8_t* pData ) override;
|
||||
|
||||
/**
|
||||
* In case data was filled manually (almost never the case).
|
||||
|
@ -35,9 +35,10 @@ uint16_t TmPacketPusC::getSourceDataSize() {
|
||||
return getPacketDataLength() - sizeof(tmData->dataField) - CRC_SIZE + 1;
|
||||
}
|
||||
|
||||
void TmPacketPusC::setData(const uint8_t* p_Data) {
|
||||
ReturnValue_t TmPacketPusC::setData(const uint8_t* p_Data) {
|
||||
SpacePacketBase::setData(p_Data);
|
||||
tmData = (TmPacketPointerPusC*) p_Data;
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -112,7 +112,7 @@ protected:
|
||||
*
|
||||
* @param p_data A pointer to another PUS Telemetry Packet.
|
||||
*/
|
||||
void setData( const uint8_t* pData );
|
||||
ReturnValue_t setData( const uint8_t* pData ) override;
|
||||
|
||||
/**
|
||||
* In case data was filled manually (almost never the case).
|
||||
|
@ -13,300 +13,300 @@ object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
|
||||
object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
|
||||
|
||||
CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId,
|
||||
uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands,
|
||||
uint16_t commandTimeoutSeconds, size_t queueDepth) :
|
||||
SystemObject(setObjectId), apid(apid), service(service),
|
||||
timeoutSeconds(commandTimeoutSeconds),
|
||||
commandMap(numberOfParallelCommands) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
||||
requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
||||
uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands,
|
||||
uint16_t commandTimeoutSeconds, size_t queueDepth) :
|
||||
SystemObject(setObjectId), apid(apid), service(service),
|
||||
timeoutSeconds(commandTimeoutSeconds),
|
||||
commandMap(numberOfParallelCommands) {
|
||||
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
||||
requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
|
||||
}
|
||||
|
||||
void CommandingServiceBase::setPacketSource(object_id_t packetSource) {
|
||||
this->packetSource = packetSource;
|
||||
this->packetSource = packetSource;
|
||||
}
|
||||
|
||||
void CommandingServiceBase::setPacketDestination(
|
||||
object_id_t packetDestination) {
|
||||
this->packetDestination = packetDestination;
|
||||
object_id_t packetDestination) {
|
||||
this->packetDestination = packetDestination;
|
||||
}
|
||||
|
||||
|
||||
CommandingServiceBase::~CommandingServiceBase() {
|
||||
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
||||
QueueFactory::instance()->deleteMessageQueue(requestQueue);
|
||||
QueueFactory::instance()->deleteMessageQueue(commandQueue);
|
||||
QueueFactory::instance()->deleteMessageQueue(requestQueue);
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t CommandingServiceBase::performOperation(uint8_t opCode) {
|
||||
handleCommandQueue();
|
||||
handleRequestQueue();
|
||||
checkTimeout();
|
||||
doPeriodicOperation();
|
||||
return RETURN_OK;
|
||||
handleCommandQueue();
|
||||
handleRequestQueue();
|
||||
checkTimeout();
|
||||
doPeriodicOperation();
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
uint16_t CommandingServiceBase::getIdentifier() {
|
||||
return service;
|
||||
return service;
|
||||
}
|
||||
|
||||
|
||||
MessageQueueId_t CommandingServiceBase::getRequestQueue() {
|
||||
return requestQueue->getId();
|
||||
return requestQueue->getId();
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t CommandingServiceBase::initialize() {
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if(packetDestination == objects::NO_OBJECT) {
|
||||
packetDestination = defaultPacketDestination;
|
||||
}
|
||||
AcceptsTelemetryIF* packetForwarding =
|
||||
ObjectManager::instance()->get<AcceptsTelemetryIF>(packetDestination);
|
||||
if(packetDestination == objects::NO_OBJECT) {
|
||||
packetDestination = defaultPacketDestination;
|
||||
}
|
||||
AcceptsTelemetryIF* packetForwarding =
|
||||
ObjectManager::instance()->get<AcceptsTelemetryIF>(packetDestination);
|
||||
|
||||
if(packetSource == objects::NO_OBJECT) {
|
||||
packetSource = defaultPacketSource;
|
||||
}
|
||||
PUSDistributorIF* distributor = ObjectManager::instance()->get<PUSDistributorIF>(
|
||||
packetSource);
|
||||
if(packetSource == objects::NO_OBJECT) {
|
||||
packetSource = defaultPacketSource;
|
||||
}
|
||||
PUSDistributorIF* distributor = ObjectManager::instance()->get<PUSDistributorIF>(
|
||||
packetSource);
|
||||
|
||||
if (packetForwarding == nullptr or distributor == nullptr) {
|
||||
if (packetForwarding == nullptr or distributor == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CommandingServiceBase::intialize: Packet source or "
|
||||
"packet destination invalid!" << std::endl;
|
||||
sif::error << "CommandingServiceBase::intialize: Packet source or "
|
||||
"packet destination invalid!" << std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
distributor->registerService(this);
|
||||
requestQueue->setDefaultDestination(
|
||||
packetForwarding->getReportReceptionQueue());
|
||||
distributor->registerService(this);
|
||||
requestQueue->setDefaultDestination(
|
||||
packetForwarding->getReportReceptionQueue());
|
||||
|
||||
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
TCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE);
|
||||
TCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE);
|
||||
|
||||
if (IPCStore == nullptr or TCStore == nullptr) {
|
||||
if (IPCStore == nullptr or TCStore == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "CommandingServiceBase::intialize: IPC store or TC store "
|
||||
"not initialized yet!" << std::endl;
|
||||
sif::error << "CommandingServiceBase::intialize: IPC store or TC store "
|
||||
"not initialized yet!" << std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
return RETURN_OK;
|
||||
|
||||
}
|
||||
|
||||
void CommandingServiceBase::handleCommandQueue() {
|
||||
CommandMessage reply;
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
while(true) {
|
||||
result = commandQueue->receiveMessage(&reply);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
handleCommandMessage(&reply);
|
||||
continue;
|
||||
}
|
||||
else if(result == MessageQueueIF::EMPTY) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
CommandMessage reply;
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
while(true) {
|
||||
result = commandQueue->receiveMessage(&reply);
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
handleCommandMessage(&reply);
|
||||
continue;
|
||||
}
|
||||
else if(result == MessageQueueIF::EMPTY) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
#if FSFW_VERBOSE_LEVEL >= 1
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::warning << "CommandingServiceBase::handleCommandQueue: Receiving message failed"
|
||||
"with code" << result << std::endl;
|
||||
sif::warning << "CommandingServiceBase::handleCommandQueue: Receiving message failed"
|
||||
"with code" << result << std::endl;
|
||||
#else
|
||||
sif::printWarning("CommandingServiceBase::handleCommandQueue: Receiving message "
|
||||
"failed with code %d\n", result);
|
||||
sif::printWarning("CommandingServiceBase::handleCommandQueue: Receiving message "
|
||||
"failed with code %d\n", result);
|
||||
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
|
||||
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
|
||||
bool isStep = false;
|
||||
CommandMessage nextCommand;
|
||||
CommandMapIter iter = commandMap.find(reply->getSender());
|
||||
bool isStep = false;
|
||||
CommandMessage nextCommand;
|
||||
CommandMapIter iter = commandMap.find(reply->getSender());
|
||||
|
||||
// handle unrequested reply first
|
||||
if (reply->getSender() == MessageQueueIF::NO_QUEUE or
|
||||
iter == commandMap.end()) {
|
||||
handleUnrequestedReply(reply);
|
||||
return;
|
||||
}
|
||||
nextCommand.setCommand(CommandMessage::CMD_NONE);
|
||||
// handle unrequested reply first
|
||||
if (reply->getSender() == MessageQueueIF::NO_QUEUE or
|
||||
iter == commandMap.end()) {
|
||||
handleUnrequestedReply(reply);
|
||||
return;
|
||||
}
|
||||
nextCommand.setCommand(CommandMessage::CMD_NONE);
|
||||
|
||||
|
||||
// Implemented by child class, specifies what to do with reply.
|
||||
ReturnValue_t result = handleReply(reply, iter->second.command, &iter->second.state,
|
||||
&nextCommand, iter->second.objectId, &isStep);
|
||||
// Implemented by child class, specifies what to do with reply.
|
||||
ReturnValue_t result = handleReply(reply, iter->second.command, &iter->second.state,
|
||||
&nextCommand, iter->second.objectId, &isStep);
|
||||
|
||||
/* If the child implementation does not implement special handling for
|
||||
* rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a
|
||||
* failure verification will be generated with the reason as the
|
||||
* return code and the initial command as failure parameter 1 */
|
||||
if((reply->getCommand() == CommandMessage::REPLY_REJECTED) and
|
||||
(result == RETURN_FAILED or result == INVALID_REPLY)) {
|
||||
result = reply->getReplyRejectedReason();
|
||||
failureParameter1 = iter->second.command;
|
||||
}
|
||||
/* If the child implementation does not implement special handling for
|
||||
* rejected replies (RETURN_FAILED or INVALID_REPLY is returned), a
|
||||
* failure verification will be generated with the reason as the
|
||||
* return code and the initial command as failure parameter 1 */
|
||||
if((reply->getCommand() == CommandMessage::REPLY_REJECTED) and
|
||||
(result == RETURN_FAILED or result == INVALID_REPLY)) {
|
||||
result = reply->getReplyRejectedReason();
|
||||
failureParameter1 = iter->second.command;
|
||||
}
|
||||
|
||||
switch (result) {
|
||||
case EXECUTION_COMPLETE:
|
||||
case RETURN_OK:
|
||||
case NO_STEP_MESSAGE:
|
||||
// handle result of reply handler implemented by developer.
|
||||
handleReplyHandlerResult(result, iter, &nextCommand, reply, isStep);
|
||||
break;
|
||||
case INVALID_REPLY:
|
||||
//might be just an unrequested reply at a bad moment
|
||||
handleUnrequestedReply(reply);
|
||||
break;
|
||||
default:
|
||||
if (isStep) {
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||
result, ++iter->second.step, failureParameter1,
|
||||
failureParameter2);
|
||||
} else {
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||
result, 0, failureParameter1, failureParameter2);
|
||||
}
|
||||
failureParameter1 = 0;
|
||||
failureParameter2 = 0;
|
||||
checkAndExecuteFifo(iter);
|
||||
break;
|
||||
}
|
||||
switch (result) {
|
||||
case EXECUTION_COMPLETE:
|
||||
case RETURN_OK:
|
||||
case NO_STEP_MESSAGE:
|
||||
// handle result of reply handler implemented by developer.
|
||||
handleReplyHandlerResult(result, iter, &nextCommand, reply, isStep);
|
||||
break;
|
||||
case INVALID_REPLY:
|
||||
//might be just an unrequested reply at a bad moment
|
||||
handleUnrequestedReply(reply);
|
||||
break;
|
||||
default:
|
||||
if (isStep) {
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||
result, ++iter->second.step, failureParameter1,
|
||||
failureParameter2);
|
||||
} else {
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||
result, 0, failureParameter1, failureParameter2);
|
||||
}
|
||||
failureParameter1 = 0;
|
||||
failureParameter2 = 0;
|
||||
checkAndExecuteFifo(iter);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void CommandingServiceBase::handleReplyHandlerResult(ReturnValue_t result,
|
||||
CommandMapIter iter, CommandMessage* nextCommand,
|
||||
CommandMessage* reply, bool& isStep) {
|
||||
iter->second.command = nextCommand->getCommand();
|
||||
CommandMapIter iter, CommandMessage* nextCommand,
|
||||
CommandMessage* reply, bool& isStep) {
|
||||
iter->second.command = nextCommand->getCommand();
|
||||
|
||||
// In case a new command is to be sent immediately, this is performed here.
|
||||
// If no new command is sent, only analyse reply result by initializing
|
||||
// sendResult as RETURN_OK
|
||||
ReturnValue_t sendResult = RETURN_OK;
|
||||
if (nextCommand->getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage(reply->getSender(),
|
||||
nextCommand);
|
||||
}
|
||||
// In case a new command is to be sent immediately, this is performed here.
|
||||
// If no new command is sent, only analyse reply result by initializing
|
||||
// sendResult as RETURN_OK
|
||||
ReturnValue_t sendResult = RETURN_OK;
|
||||
if (nextCommand->getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage(reply->getSender(),
|
||||
nextCommand);
|
||||
}
|
||||
|
||||
if (sendResult == RETURN_OK) {
|
||||
if (isStep and result != NO_STEP_MESSAGE) {
|
||||
verificationReporter.sendSuccessReport(
|
||||
tc_verification::PROGRESS_SUCCESS,
|
||||
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, ++iter->second.step);
|
||||
}
|
||||
else {
|
||||
verificationReporter.sendSuccessReport(
|
||||
tc_verification::COMPLETION_SUCCESS,
|
||||
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, 0);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isStep) {
|
||||
nextCommand->clearCommandMessage();
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, sendResult,
|
||||
++iter->second.step, failureParameter1, failureParameter2);
|
||||
} else {
|
||||
nextCommand->clearCommandMessage();
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE,
|
||||
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, sendResult, 0,
|
||||
failureParameter1, failureParameter2);
|
||||
}
|
||||
failureParameter1 = 0;
|
||||
failureParameter2 = 0;
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
if (sendResult == RETURN_OK) {
|
||||
if (isStep and result != NO_STEP_MESSAGE) {
|
||||
verificationReporter.sendSuccessReport(
|
||||
tc_verification::PROGRESS_SUCCESS,
|
||||
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, ++iter->second.step);
|
||||
}
|
||||
else {
|
||||
verificationReporter.sendSuccessReport(
|
||||
tc_verification::COMPLETION_SUCCESS,
|
||||
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, 0);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isStep) {
|
||||
nextCommand->clearCommandMessage();
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::PROGRESS_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, sendResult,
|
||||
++iter->second.step, failureParameter1, failureParameter2);
|
||||
} else {
|
||||
nextCommand->clearCommandMessage();
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE,
|
||||
iter->second.tcInfo.ackFlags, iter->second.tcInfo.tcPacketId,
|
||||
iter->second.tcInfo.tcSequenceControl, sendResult, 0,
|
||||
failureParameter1, failureParameter2);
|
||||
}
|
||||
failureParameter1 = 0;
|
||||
failureParameter2 = 0;
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandingServiceBase::handleRequestQueue() {
|
||||
TmTcMessage message;
|
||||
ReturnValue_t result;
|
||||
store_address_t address;
|
||||
TcPacketStoredPus packet;
|
||||
MessageQueueId_t queue;
|
||||
object_id_t objectId;
|
||||
for (result = requestQueue->receiveMessage(&message); result == RETURN_OK;
|
||||
result = requestQueue->receiveMessage(&message)) {
|
||||
address = message.getStorageId();
|
||||
packet.setStoreAddress(address);
|
||||
TmTcMessage message;
|
||||
ReturnValue_t result;
|
||||
store_address_t address;
|
||||
TcPacketStoredPus packet;
|
||||
MessageQueueId_t queue;
|
||||
object_id_t objectId;
|
||||
for (result = requestQueue->receiveMessage(&message); result == RETURN_OK;
|
||||
result = requestQueue->receiveMessage(&message)) {
|
||||
address = message.getStorageId();
|
||||
packet.setStoreAddress(address, &packet);
|
||||
|
||||
if ((packet.getSubService() == 0)
|
||||
or (isValidSubservice(packet.getSubService()) != RETURN_OK)) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE);
|
||||
continue;
|
||||
}
|
||||
if ((packet.getSubService() == 0)
|
||||
or (isValidSubservice(packet.getSubService()) != RETURN_OK)) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, INVALID_SUBSERVICE);
|
||||
continue;
|
||||
}
|
||||
|
||||
result = getMessageQueueAndObject(packet.getSubService(),
|
||||
packet.getApplicationData(), packet.getApplicationDataSize(),
|
||||
&queue, &objectId);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, result);
|
||||
continue;
|
||||
}
|
||||
result = getMessageQueueAndObject(packet.getSubService(),
|
||||
packet.getApplicationData(), packet.getApplicationDataSize(),
|
||||
&queue, &objectId);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, result);
|
||||
continue;
|
||||
}
|
||||
|
||||
//Is a command already active for the target object?
|
||||
CommandMapIter iter;
|
||||
iter = commandMap.find(queue);
|
||||
//Is a command already active for the target object?
|
||||
CommandMapIter iter;
|
||||
iter = commandMap.find(queue);
|
||||
|
||||
if (iter != commandMap.end()) {
|
||||
result = iter->second.fifo.insert(address);
|
||||
if (result != RETURN_OK) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, OBJECT_BUSY);
|
||||
}
|
||||
} else {
|
||||
CommandInfo newInfo; //Info will be set by startExecution if neccessary
|
||||
newInfo.objectId = objectId;
|
||||
result = commandMap.insert(queue, newInfo, &iter);
|
||||
if (result != RETURN_OK) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, BUSY);
|
||||
} else {
|
||||
startExecution(&packet, iter);
|
||||
}
|
||||
}
|
||||
if (iter != commandMap.end()) {
|
||||
result = iter->second.fifo.insert(address);
|
||||
if (result != RETURN_OK) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, OBJECT_BUSY);
|
||||
}
|
||||
} else {
|
||||
CommandInfo newInfo; //Info will be set by startExecution if neccessary
|
||||
newInfo.objectId = objectId;
|
||||
result = commandMap.insert(queue, newInfo, &iter);
|
||||
if (result != RETURN_OK) {
|
||||
rejectPacket(tc_verification::START_FAILURE, &packet, BUSY);
|
||||
} else {
|
||||
startExecution(&packet, iter);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
const uint8_t* data, size_t dataLen, const uint8_t* headerData,
|
||||
size_t headerSize) {
|
||||
const uint8_t* data, size_t dataLen, const uint8_t* headerData,
|
||||
size_t headerSize) {
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, headerData, headerSize);
|
||||
TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, headerData, headerSize);
|
||||
#else
|
||||
TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice,
|
||||
TmPacketStoredPusC tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, headerData, headerSize);
|
||||
#endif
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
this->tmPacketCounter++;
|
||||
}
|
||||
return result;
|
||||
ReturnValue_t result = tmPacketStored.sendPacket(
|
||||
requestQueue->getDefaultDestination(), requestQueue->getId());
|
||||
if (result == HasReturnvaluesIF::RETURN_OK) {
|
||||
this->tmPacketCounter++;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -316,7 +316,7 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
uint8_t* pBuffer = buffer;
|
||||
size_t size = 0;
|
||||
SerializeAdapter::serialize(&objectId, &pBuffer, &size,
|
||||
sizeof(object_id_t), SerializeIF::Endianness::BIG);
|
||||
sizeof(object_id_t), SerializeIF::Endianness::BIG);
|
||||
#if FSFW_USE_PUS_C_TELEMETRY == 0
|
||||
TmPacketStoredPusA tmPacketStored(this->apid, this->service, subservice,
|
||||
this->tmPacketCounter, data, dataLen, buffer, size);
|
||||
@ -351,95 +351,96 @@ ReturnValue_t CommandingServiceBase::sendTmPacket(uint8_t subservice,
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::startExecution(TcPacketStoredBase *storedPacket,
|
||||
void CommandingServiceBase::startExecution(TcPacketStoredPus* storedPacket,
|
||||
CommandMapIter iter) {
|
||||
ReturnValue_t result = RETURN_OK;
|
||||
CommandMessage command;
|
||||
TcPacketBase* tcPacketBase = storedPacket->getPacketBase();
|
||||
if(tcPacketBase == nullptr) {
|
||||
//TcPacketPusBase* tcPacketBase = storedPacket->getPacketBase();
|
||||
if(storedPacket == nullptr) {
|
||||
return;
|
||||
}
|
||||
iter->second.subservice = tcPacketBase->getSubService();
|
||||
iter->second.subservice = storedPacket->getSubService();
|
||||
result = prepareCommand(&command, iter->second.subservice,
|
||||
tcPacketBase->getApplicationData(),
|
||||
tcPacketBase->getApplicationDataSize(), &iter->second.state,
|
||||
storedPacket->getApplicationData(),
|
||||
storedPacket->getApplicationDataSize(), &iter->second.state,
|
||||
iter->second.objectId);
|
||||
|
||||
ReturnValue_t sendResult = RETURN_OK;
|
||||
switch (result) {
|
||||
case RETURN_OK:
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||
&command);
|
||||
}
|
||||
if (sendResult == RETURN_OK) {
|
||||
Clock::getUptime(&iter->second.uptimeOfStart);
|
||||
iter->second.step = 0;
|
||||
iter->second.subservice = tcPacketBase->getSubService();
|
||||
iter->second.command = command.getCommand();
|
||||
iter->second.tcInfo.ackFlags = tcPacketBase->getAcknowledgeFlags();
|
||||
iter->second.tcInfo.tcPacketId = tcPacketBase->getPacketId();
|
||||
iter->second.tcInfo.tcSequenceControl =
|
||||
tcPacketBase->getPacketSequenceControl();
|
||||
acceptPacket(tc_verification::START_SUCCESS, storedPacket);
|
||||
} else {
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
break;
|
||||
case EXECUTION_COMPLETE:
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
//Fire-and-forget command.
|
||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||
&command);
|
||||
}
|
||||
if (sendResult == RETURN_OK) {
|
||||
verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS,
|
||||
storedPacket->getPacketBase());
|
||||
acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket);
|
||||
checkAndExecuteFifo(iter);
|
||||
} else {
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rejectPacket(tc_verification::START_FAILURE, storedPacket, result);
|
||||
checkAndExecuteFifo(iter);
|
||||
break;
|
||||
}
|
||||
switch (result) {
|
||||
case RETURN_OK:
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||
&command);
|
||||
}
|
||||
if (sendResult == RETURN_OK) {
|
||||
Clock::getUptime(&iter->second.uptimeOfStart);
|
||||
iter->second.step = 0;
|
||||
iter->second.subservice = storedPacket->getSubService();
|
||||
iter->second.command = command.getCommand();
|
||||
iter->second.tcInfo.ackFlags = storedPacket->getAcknowledgeFlags();
|
||||
iter->second.tcInfo.tcPacketId = storedPacket->getPacketId();
|
||||
iter->second.tcInfo.tcSequenceControl =
|
||||
storedPacket->getPacketSequenceControl();
|
||||
acceptPacket(tc_verification::START_SUCCESS, storedPacket);
|
||||
} else {
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
break;
|
||||
case EXECUTION_COMPLETE:
|
||||
if (command.getCommand() != CommandMessage::CMD_NONE) {
|
||||
//Fire-and-forget command.
|
||||
sendResult = commandQueue->sendMessage(iter.value->first,
|
||||
&command);
|
||||
}
|
||||
if (sendResult == RETURN_OK) {
|
||||
verificationReporter.sendSuccessReport(tc_verification::START_SUCCESS,
|
||||
storedPacket->getPacketBase());
|
||||
acceptPacket(tc_verification::COMPLETION_SUCCESS, storedPacket);
|
||||
checkAndExecuteFifo(iter);
|
||||
} else {
|
||||
command.clearCommandMessage();
|
||||
rejectPacket(tc_verification::START_FAILURE, storedPacket, sendResult);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
rejectPacket(tc_verification::START_FAILURE, storedPacket, result);
|
||||
checkAndExecuteFifo(iter);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::rejectPacket(uint8_t reportId,
|
||||
TcPacketStoredBase* packet, ReturnValue_t errorCode) {
|
||||
verificationReporter.sendFailureReport(reportId, packet->getPacketBase(), errorCode);
|
||||
packet->deletePacket();
|
||||
TcPacketStoredPus* packet, ReturnValue_t errorCode) {
|
||||
verificationReporter.sendFailureReport(reportId, dynamic_cast<TcPacketPusBase*>(packet),
|
||||
errorCode);
|
||||
packet->deletePacket();
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::acceptPacket(uint8_t reportId,
|
||||
TcPacketStoredBase* packet) {
|
||||
verificationReporter.sendSuccessReport(reportId, packet->getPacketBase());
|
||||
packet->deletePacket();
|
||||
TcPacketStoredPus* packet) {
|
||||
verificationReporter.sendSuccessReport(reportId, dynamic_cast<TcPacketPusBase*>(packet));
|
||||
packet->deletePacket();
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::checkAndExecuteFifo(CommandMapIter& iter) {
|
||||
store_address_t address;
|
||||
if (iter->second.fifo.retrieve(&address) != RETURN_OK) {
|
||||
commandMap.erase(&iter);
|
||||
} else {
|
||||
TcPacketStoredPus newPacket(address);
|
||||
startExecution(&newPacket, iter);
|
||||
}
|
||||
store_address_t address;
|
||||
if (iter->second.fifo.retrieve(&address) != RETURN_OK) {
|
||||
commandMap.erase(&iter);
|
||||
} else {
|
||||
TcPacketStoredPus newPacket(address);
|
||||
startExecution(&newPacket, iter);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommandingServiceBase::handleUnrequestedReply(CommandMessage* reply) {
|
||||
reply->clearCommandMessage();
|
||||
reply->clearCommandMessage();
|
||||
}
|
||||
|
||||
|
||||
@ -447,22 +448,22 @@ inline void CommandingServiceBase::doPeriodicOperation() {
|
||||
}
|
||||
|
||||
MessageQueueId_t CommandingServiceBase::getCommandQueue() {
|
||||
return commandQueue->getId();
|
||||
return commandQueue->getId();
|
||||
}
|
||||
|
||||
void CommandingServiceBase::checkTimeout() {
|
||||
uint32_t uptime;
|
||||
Clock::getUptime(&uptime);
|
||||
CommandMapIter iter;
|
||||
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
|
||||
if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||
TIMEOUT);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
uint32_t uptime;
|
||||
Clock::getUptime(&uptime);
|
||||
CommandMapIter iter;
|
||||
for (iter = commandMap.begin(); iter != commandMap.end(); ++iter) {
|
||||
if ((iter->second.uptimeOfStart + (timeoutSeconds * 1000)) < uptime) {
|
||||
verificationReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE, iter->second.tcInfo.ackFlags,
|
||||
iter->second.tcInfo.tcPacketId, iter->second.tcInfo.tcSequenceControl,
|
||||
TIMEOUT);
|
||||
checkAndExecuteFifo(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandingServiceBase::setTaskIF(PeriodicTaskIF* task_) {
|
||||
|
@ -14,8 +14,8 @@
|
||||
#include "fsfw/container/FIFO.h"
|
||||
#include "fsfw/serialize/SerializeIF.h"
|
||||
|
||||
class TcPacketStored;
|
||||
class TcPacketStoredBase;
|
||||
class TcPacketStoredPus;
|
||||
|
||||
namespace Factory{
|
||||
void setStaticFrameworkObjectIds();
|
||||
@ -36,333 +36,333 @@ void setStaticFrameworkObjectIds();
|
||||
* @ingroup pus_services
|
||||
*/
|
||||
class CommandingServiceBase: public SystemObject,
|
||||
public AcceptsTelecommandsIF,
|
||||
public ExecutableObjectIF,
|
||||
public HasReturnvaluesIF {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public AcceptsTelecommandsIF,
|
||||
public ExecutableObjectIF,
|
||||
public HasReturnvaluesIF {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
// We could make this configurable via preprocessor and the FSFWConfig file.
|
||||
static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH =
|
||||
fsfwconfig::FSFW_CSB_FIFO_DEPTH;
|
||||
// We could make this configurable via preprocessor and the FSFWConfig file.
|
||||
static constexpr uint8_t COMMAND_INFO_FIFO_DEPTH =
|
||||
fsfwconfig::FSFW_CSB_FIFO_DEPTH;
|
||||
|
||||
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 NO_STEP_MESSAGE = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t OBJECT_BUSY = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(4);
|
||||
static const ReturnValue_t INVALID_TC = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t INVALID_OBJECT = MAKE_RETURN_CODE(6);
|
||||
static const ReturnValue_t INVALID_REPLY = MAKE_RETURN_CODE(7);
|
||||
static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1);
|
||||
static const ReturnValue_t NO_STEP_MESSAGE = MAKE_RETURN_CODE(2);
|
||||
static const ReturnValue_t OBJECT_BUSY = MAKE_RETURN_CODE(3);
|
||||
static const ReturnValue_t BUSY = MAKE_RETURN_CODE(4);
|
||||
static const ReturnValue_t INVALID_TC = MAKE_RETURN_CODE(5);
|
||||
static const ReturnValue_t INVALID_OBJECT = MAKE_RETURN_CODE(6);
|
||||
static const ReturnValue_t INVALID_REPLY = MAKE_RETURN_CODE(7);
|
||||
|
||||
/**
|
||||
* Class constructor. Initializes two important MessageQueues:
|
||||
* commandQueue for command reception and requestQueue for device reception
|
||||
* @param setObjectId
|
||||
* @param apid
|
||||
* @param service
|
||||
* @param numberOfParallelCommands
|
||||
* @param commandTimeout_seconds
|
||||
* @param setPacketSource
|
||||
* @param setPacketDestination
|
||||
* @param queueDepth
|
||||
*/
|
||||
CommandingServiceBase(object_id_t setObjectId, uint16_t apid,
|
||||
uint8_t service, uint8_t numberOfParallelCommands,
|
||||
uint16_t commandTimeoutSeconds, size_t queueDepth = 20);
|
||||
virtual ~CommandingServiceBase();
|
||||
/**
|
||||
* Class constructor. Initializes two important MessageQueues:
|
||||
* commandQueue for command reception and requestQueue for device reception
|
||||
* @param setObjectId
|
||||
* @param apid
|
||||
* @param service
|
||||
* @param numberOfParallelCommands
|
||||
* @param commandTimeout_seconds
|
||||
* @param setPacketSource
|
||||
* @param setPacketDestination
|
||||
* @param queueDepth
|
||||
*/
|
||||
CommandingServiceBase(object_id_t setObjectId, uint16_t apid,
|
||||
uint8_t service, uint8_t numberOfParallelCommands,
|
||||
uint16_t commandTimeoutSeconds, size_t queueDepth = 20);
|
||||
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 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.
|
||||
* Handle request queue for external commands.
|
||||
* Handle command Queue for internal commands.
|
||||
* @param opCode is unused here at the moment
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
/***
|
||||
* This is the periodically called function.
|
||||
* Handle request queue for external commands.
|
||||
* Handle command Queue for internal commands.
|
||||
* @param opCode is unused here at the moment
|
||||
* @return RETURN_OK
|
||||
*/
|
||||
virtual ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
|
||||
virtual uint16_t getIdentifier();
|
||||
virtual uint16_t getIdentifier();
|
||||
|
||||
/**
|
||||
* Returns the requestQueue MessageQueueId_t
|
||||
*
|
||||
* The requestQueue is the queue for external commands (TC)
|
||||
*
|
||||
* @return requestQueue messageQueueId_t
|
||||
*/
|
||||
virtual MessageQueueId_t getRequestQueue();
|
||||
/**
|
||||
* Returns the requestQueue MessageQueueId_t
|
||||
*
|
||||
* The requestQueue is the queue for external commands (TC)
|
||||
*
|
||||
* @return requestQueue messageQueueId_t
|
||||
*/
|
||||
virtual MessageQueueId_t getRequestQueue();
|
||||
|
||||
/**
|
||||
* Returns the commandQueue MessageQueueId_t
|
||||
*
|
||||
* Remember the CommandQueue is the queue for internal communication
|
||||
* @return commandQueue messageQueueId_t
|
||||
*/
|
||||
virtual MessageQueueId_t getCommandQueue();
|
||||
/**
|
||||
* Returns the commandQueue MessageQueueId_t
|
||||
*
|
||||
* Remember the CommandQueue is the queue for internal communication
|
||||
* @return commandQueue messageQueueId_t
|
||||
*/
|
||||
virtual MessageQueueId_t getCommandQueue();
|
||||
|
||||
virtual ReturnValue_t initialize() override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
/**
|
||||
* Implementation of ExecutableObjectIF function
|
||||
*
|
||||
* Used to setup the reference of the task, that executes this component
|
||||
* @param task Pointer to the taskIF of this task
|
||||
*/
|
||||
virtual void setTaskIF(PeriodicTaskIF* task) override;
|
||||
/**
|
||||
* Implementation of ExecutableObjectIF function
|
||||
*
|
||||
* Used to setup the reference of the task, that executes this component
|
||||
* @param task Pointer to the taskIF of this task
|
||||
*/
|
||||
virtual void setTaskIF(PeriodicTaskIF* task) override;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Check the target subservice
|
||||
* @param subservice[in]
|
||||
* @return
|
||||
* -@c RETURN_OK Subservice valid, continue message handling
|
||||
/**
|
||||
* Check the target subservice
|
||||
* @param subservice[in]
|
||||
* @return
|
||||
* -@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;
|
||||
|
||||
/**
|
||||
* Once a TC Request is valid, the existence of the destination and its
|
||||
* target interface is checked and retrieved. The target message queue ID
|
||||
* can then be acquired by using the target interface.
|
||||
* @param subservice
|
||||
* @param tcData Application Data of TC Packet
|
||||
* @param tcDataLen
|
||||
* @param id MessageQueue ID is stored here
|
||||
* @param objectId Object ID is extracted and stored here
|
||||
* @return
|
||||
* - @c RETURN_OK Cotinue message handling
|
||||
* - @c RETURN_FAILED Reject the packet and generates a start failure
|
||||
* verification
|
||||
*/
|
||||
virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
|
||||
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
|
||||
object_id_t *objectId) = 0;
|
||||
/**
|
||||
* Once a TC Request is valid, the existence of the destination and its
|
||||
* target interface is checked and retrieved. The target message queue ID
|
||||
* can then be acquired by using the target interface.
|
||||
* @param subservice
|
||||
* @param tcData Application Data of TC Packet
|
||||
* @param tcDataLen
|
||||
* @param id MessageQueue ID is stored here
|
||||
* @param objectId Object ID is extracted and stored here
|
||||
* @return
|
||||
* - @c RETURN_OK Cotinue message handling
|
||||
* - @c RETURN_FAILED Reject the packet and generates a start failure
|
||||
* verification
|
||||
*/
|
||||
virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
|
||||
const uint8_t *tcData, size_t tcDataLen, MessageQueueId_t *id,
|
||||
object_id_t *objectId) = 0;
|
||||
|
||||
/**
|
||||
* After the Message Queue and Object ID are determined, the command is
|
||||
* prepared by using an implementation specific CommandMessage type
|
||||
* which is sent to the target object. It contains all necessary information
|
||||
* for the device to execute telecommands.
|
||||
* @param message [out] message which can be set and is sent to the object
|
||||
* @param subservice Subservice of the current communication
|
||||
* @param tcData Application data of command
|
||||
* @param tcDataLen Application data length
|
||||
* @param state [out/in] Setable state of the communication.
|
||||
* communication
|
||||
* @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
|
||||
* verification message.
|
||||
* - @c Anything else rejects the packets and generates a start failure
|
||||
* verification.
|
||||
*/
|
||||
virtual ReturnValue_t prepareCommand(CommandMessage* message,
|
||||
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
|
||||
uint32_t *state, object_id_t objectId) = 0;
|
||||
/**
|
||||
* After the Message Queue and Object ID are determined, the command is
|
||||
* prepared by using an implementation specific CommandMessage type
|
||||
* which is sent to the target object. It contains all necessary information
|
||||
* for the device to execute telecommands.
|
||||
* @param message [out] message which can be set and is sent to the object
|
||||
* @param subservice Subservice of the current communication
|
||||
* @param tcData Application data of command
|
||||
* @param tcDataLen Application data length
|
||||
* @param state [out/in] Setable state of the communication.
|
||||
* communication
|
||||
* @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
|
||||
* verification message.
|
||||
* - @c Anything else rejects the packets and generates a start failure
|
||||
* verification.
|
||||
*/
|
||||
virtual ReturnValue_t prepareCommand(CommandMessage* message,
|
||||
uint8_t subservice, const uint8_t *tcData, size_t tcDataLen,
|
||||
uint32_t *state, object_id_t objectId) = 0;
|
||||
|
||||
/**
|
||||
* This function is implemented by child services to specify how replies
|
||||
* to a command from another software component are handled.
|
||||
* @param reply
|
||||
* This is the reply in form of a generic read-only command message.
|
||||
* @param previousCommand
|
||||
* Command_t of related command
|
||||
* @param state [out/in]
|
||||
* Additional parameter which can be used to pass state information.
|
||||
* State of the communication
|
||||
* @param optionalNextCommand [out]
|
||||
* An optional next command which can be set in this function
|
||||
* @param objectId Source object ID
|
||||
* @param isStep Flag value to mark steps of command execution
|
||||
* @return
|
||||
* - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to
|
||||
* generate TC verification success
|
||||
* - @c INVALID_REPLY Calls handleUnrequestedReply
|
||||
* - Anything else triggers a TC verification failure. If RETURN_FAILED or
|
||||
* INVALID_REPLY is returned and the command ID is
|
||||
* CommandMessage::REPLY_REJECTED, a failure verification message with
|
||||
* the reason as the error parameter and the initial command as
|
||||
* failure parameter 1 is generated.
|
||||
*/
|
||||
virtual ReturnValue_t handleReply(const CommandMessage* reply,
|
||||
Command_t previousCommand, uint32_t *state,
|
||||
CommandMessage* optionalNextCommand, object_id_t objectId,
|
||||
bool *isStep) = 0;
|
||||
/**
|
||||
* This function is implemented by child services to specify how replies
|
||||
* to a command from another software component are handled.
|
||||
* @param reply
|
||||
* This is the reply in form of a generic read-only command message.
|
||||
* @param previousCommand
|
||||
* Command_t of related command
|
||||
* @param state [out/in]
|
||||
* Additional parameter which can be used to pass state information.
|
||||
* State of the communication
|
||||
* @param optionalNextCommand [out]
|
||||
* An optional next command which can be set in this function
|
||||
* @param objectId Source object ID
|
||||
* @param isStep Flag value to mark steps of command execution
|
||||
* @return
|
||||
* - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to
|
||||
* generate TC verification success
|
||||
* - @c INVALID_REPLY Calls handleUnrequestedReply
|
||||
* - Anything else triggers a TC verification failure. If RETURN_FAILED or
|
||||
* INVALID_REPLY is returned and the command ID is
|
||||
* CommandMessage::REPLY_REJECTED, a failure verification message with
|
||||
* the reason as the error parameter and the initial command as
|
||||
* failure parameter 1 is generated.
|
||||
*/
|
||||
virtual ReturnValue_t handleReply(const CommandMessage* reply,
|
||||
Command_t previousCommand, uint32_t *state,
|
||||
CommandMessage* optionalNextCommand, object_id_t objectId,
|
||||
bool *isStep) = 0;
|
||||
|
||||
/**
|
||||
* This function can be overidden to handle unrequested reply,
|
||||
* when the reply sender ID is unknown or is not found is the command map.
|
||||
* The default implementation will clear the command message and all
|
||||
* its contents.
|
||||
* @param reply
|
||||
* Reply which is non-const so the default implementation can clear the
|
||||
* message.
|
||||
*/
|
||||
virtual void handleUnrequestedReply(CommandMessage* reply);
|
||||
/**
|
||||
* This function can be overidden to handle unrequested reply,
|
||||
* when the reply sender ID is unknown or is not found is the command map.
|
||||
* The default implementation will clear the command message and all
|
||||
* its contents.
|
||||
* @param reply
|
||||
* Reply which is non-const so the default implementation can clear the
|
||||
* message.
|
||||
*/
|
||||
virtual void handleUnrequestedReply(CommandMessage* reply);
|
||||
|
||||
virtual void doPeriodicOperation();
|
||||
virtual void doPeriodicOperation();
|
||||
|
||||
struct CommandInfo: public SerializeIF{
|
||||
struct tcInfo {
|
||||
uint8_t ackFlags;
|
||||
uint16_t tcPacketId;
|
||||
uint16_t tcSequenceControl;
|
||||
} tcInfo;
|
||||
uint32_t uptimeOfStart;
|
||||
uint8_t step;
|
||||
uint8_t subservice;
|
||||
uint32_t state;
|
||||
Command_t command;
|
||||
object_id_t objectId;
|
||||
FIFO<store_address_t, COMMAND_INFO_FIFO_DEPTH> fifo;
|
||||
struct CommandInfo: public SerializeIF{
|
||||
struct tcInfo {
|
||||
uint8_t ackFlags;
|
||||
uint16_t tcPacketId;
|
||||
uint16_t tcSequenceControl;
|
||||
} tcInfo;
|
||||
uint32_t uptimeOfStart;
|
||||
uint8_t step;
|
||||
uint8_t subservice;
|
||||
uint32_t state;
|
||||
Command_t command;
|
||||
object_id_t objectId;
|
||||
FIFO<store_address_t, COMMAND_INFO_FIFO_DEPTH> fifo;
|
||||
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
size_t maxSize, Endianness streamEndianness) const override{
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
virtual ReturnValue_t serialize(uint8_t **buffer, size_t *size,
|
||||
size_t maxSize, Endianness streamEndianness) const override{
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
|
||||
virtual size_t getSerializedSize() const override {
|
||||
return 0;
|
||||
};
|
||||
virtual size_t getSerializedSize() const override {
|
||||
return 0;
|
||||
};
|
||||
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
};
|
||||
virtual ReturnValue_t deSerialize(const uint8_t **buffer, size_t *size,
|
||||
Endianness streamEndianness) override {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
};
|
||||
};
|
||||
|
||||
using CommandMapIter = FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator;
|
||||
using CommandMapIter = FixedMap<MessageQueueId_t,
|
||||
CommandingServiceBase::CommandInfo>::Iterator;
|
||||
|
||||
const uint16_t apid;
|
||||
const uint16_t apid;
|
||||
|
||||
const uint8_t service;
|
||||
const uint8_t service;
|
||||
|
||||
const uint16_t timeoutSeconds;
|
||||
const uint16_t timeoutSeconds;
|
||||
|
||||
uint8_t tmPacketCounter = 0;
|
||||
uint8_t tmPacketCounter = 0;
|
||||
|
||||
StorageManagerIF *IPCStore = nullptr;
|
||||
StorageManagerIF *IPCStore = nullptr;
|
||||
|
||||
StorageManagerIF *TCStore = nullptr;
|
||||
StorageManagerIF *TCStore = nullptr;
|
||||
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
MessageQueueIF* commandQueue = nullptr;
|
||||
|
||||
MessageQueueIF* requestQueue = nullptr;
|
||||
MessageQueueIF* requestQueue = nullptr;
|
||||
|
||||
VerificationReporter verificationReporter;
|
||||
VerificationReporter verificationReporter;
|
||||
|
||||
FixedMap<MessageQueueId_t, CommandInfo> commandMap;
|
||||
FixedMap<MessageQueueId_t, CommandInfo> commandMap;
|
||||
|
||||
/* May be set be children to return a more precise failure condition. */
|
||||
uint32_t failureParameter1 = 0;
|
||||
uint32_t failureParameter2 = 0;
|
||||
/* May be set be children to return a more precise failure condition. */
|
||||
uint32_t failureParameter1 = 0;
|
||||
uint32_t failureParameter2 = 0;
|
||||
|
||||
static object_id_t defaultPacketSource;
|
||||
object_id_t packetSource = objects::NO_OBJECT;
|
||||
static object_id_t defaultPacketDestination;
|
||||
object_id_t packetDestination = objects::NO_OBJECT;
|
||||
static object_id_t defaultPacketSource;
|
||||
object_id_t packetSource = objects::NO_OBJECT;
|
||||
static object_id_t defaultPacketDestination;
|
||||
object_id_t packetDestination = objects::NO_OBJECT;
|
||||
|
||||
/**
|
||||
* Pointer to the task which executes this component,
|
||||
* is invalid before setTaskIF was called.
|
||||
*/
|
||||
PeriodicTaskIF* executingTask = nullptr;
|
||||
/**
|
||||
* Pointer to the task which executes this component,
|
||||
* is invalid before setTaskIF was called.
|
||||
*/
|
||||
PeriodicTaskIF* executingTask = nullptr;
|
||||
|
||||
/**
|
||||
* @brief Send TM data from pointer to data.
|
||||
* If a header is supplied it is added before data
|
||||
* @param subservice Number of subservice
|
||||
* @param data Pointer to the data in the Packet
|
||||
* @param dataLen Lenght of data in the Packet
|
||||
* @param headerData HeaderData will be placed before data
|
||||
* @param headerSize Size of HeaderData
|
||||
*/
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t *data,
|
||||
size_t dataLen, const uint8_t* headerData = nullptr,
|
||||
size_t headerSize = 0);
|
||||
/**
|
||||
* @brief Send TM data from pointer to data.
|
||||
* If a header is supplied it is added before data
|
||||
* @param subservice Number of subservice
|
||||
* @param data Pointer to the data in the Packet
|
||||
* @param dataLen Lenght of data in the Packet
|
||||
* @param headerData HeaderData will be placed before data
|
||||
* @param headerSize Size of HeaderData
|
||||
*/
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t *data,
|
||||
size_t dataLen, const uint8_t* headerData = nullptr,
|
||||
size_t headerSize = 0);
|
||||
|
||||
/**
|
||||
* @brief To send TM packets of objects that still need to be serialized
|
||||
* and consist of an object ID with appended data.
|
||||
* @param subservice Number of subservice
|
||||
* @param objectId ObjectId is placed before data
|
||||
* @param data Data to append to the packet
|
||||
* @param dataLen Length of Data
|
||||
*/
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId,
|
||||
const uint8_t *data, size_t dataLen);
|
||||
/**
|
||||
* @brief To send TM packets of objects that still need to be serialized
|
||||
* and consist of an object ID with appended data.
|
||||
* @param subservice Number of subservice
|
||||
* @param objectId ObjectId is placed before data
|
||||
* @param data Data to append to the packet
|
||||
* @param dataLen Length of Data
|
||||
*/
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId,
|
||||
const uint8_t *data, size_t dataLen);
|
||||
|
||||
/**
|
||||
* @brief To send packets which are contained inside a class implementing
|
||||
* SerializeIF.
|
||||
* @param subservice Number of subservice
|
||||
* @param content This is a pointer to the serialized packet
|
||||
* @param header Serialize IF header which will be placed before content
|
||||
*/
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* content,
|
||||
SerializeIF* header = nullptr);
|
||||
/**
|
||||
* @brief To send packets which are contained inside a class implementing
|
||||
* SerializeIF.
|
||||
* @param subservice Number of subservice
|
||||
* @param content This is a pointer to the serialized packet
|
||||
* @param header Serialize IF header which will be placed before content
|
||||
*/
|
||||
ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF* content,
|
||||
SerializeIF* header = nullptr);
|
||||
|
||||
void checkAndExecuteFifo(CommandMapIter& iter);
|
||||
void checkAndExecuteFifo(CommandMapIter& iter);
|
||||
|
||||
private:
|
||||
/**
|
||||
* This method handles internal execution of a command,
|
||||
* once it has been started by @sa{startExecution()} in the request
|
||||
* queue handler.
|
||||
* It handles replies generated by the devices and relayed by the specific
|
||||
* service implementation. This means that it determines further course of
|
||||
* action depending on the return values specified in the service
|
||||
* implementation.
|
||||
* This includes the generation of TC verification messages. Note that
|
||||
* the static framework object ID @c VerificationReporter::messageReceiver
|
||||
* needs to be set.
|
||||
* - TM[1,5] Step Successs
|
||||
* - TM[1,6] Step Failure
|
||||
* - TM[1,7] Completion Success
|
||||
* - TM[1,8] Completion Failure
|
||||
*/
|
||||
void handleCommandQueue();
|
||||
private:
|
||||
/**
|
||||
* This method handles internal execution of a command,
|
||||
* once it has been started by @sa{startExecution()} in the request
|
||||
* queue handler.
|
||||
* It handles replies generated by the devices and relayed by the specific
|
||||
* service implementation. This means that it determines further course of
|
||||
* action depending on the return values specified in the service
|
||||
* implementation.
|
||||
* This includes the generation of TC verification messages. Note that
|
||||
* the static framework object ID @c VerificationReporter::messageReceiver
|
||||
* needs to be set.
|
||||
* - TM[1,5] Step Successs
|
||||
* - TM[1,6] Step Failure
|
||||
* - TM[1,7] Completion Success
|
||||
* - TM[1,8] Completion Failure
|
||||
*/
|
||||
void handleCommandQueue();
|
||||
|
||||
/**
|
||||
* @brief Handler function for request queue
|
||||
* @details
|
||||
* Sequence of request queue handling:
|
||||
* isValidSubservice -> getMessageQueueAndObject -> startExecution
|
||||
* Generates a Start Success Reports TM[1,3] in subfunction
|
||||
* @sa{startExecution()} or a Start Failure Report TM[1,4] by using the
|
||||
* TC Verification Service.
|
||||
*/
|
||||
void handleRequestQueue();
|
||||
/**
|
||||
* @brief Handler function for request queue
|
||||
* @details
|
||||
* Sequence of request queue handling:
|
||||
* isValidSubservice -> getMessageQueueAndObject -> startExecution
|
||||
* Generates a Start Success Reports TM[1,3] in subfunction
|
||||
* @sa{startExecution()} or a Start Failure Report TM[1,4] by using the
|
||||
* TC Verification Service.
|
||||
*/
|
||||
void handleRequestQueue();
|
||||
|
||||
void rejectPacket(uint8_t reportId, TcPacketStoredBase* packet,
|
||||
ReturnValue_t errorCode);
|
||||
void rejectPacket(uint8_t reportId, TcPacketStoredPus* packet,
|
||||
ReturnValue_t errorCode);
|
||||
|
||||
void acceptPacket(uint8_t reportId, TcPacketStoredBase* packet);
|
||||
void acceptPacket(uint8_t reportId, TcPacketStoredPus* packet);
|
||||
|
||||
void startExecution(TcPacketStoredBase *storedPacket, CommandMapIter iter);
|
||||
void startExecution(TcPacketStoredPus* storedPacket, CommandMapIter iter);
|
||||
|
||||
void handleCommandMessage(CommandMessage* reply);
|
||||
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
|
||||
CommandMessage* nextCommand, CommandMessage* reply, bool& isStep);
|
||||
void handleCommandMessage(CommandMessage* reply);
|
||||
void handleReplyHandlerResult(ReturnValue_t result, CommandMapIter iter,
|
||||
CommandMessage* nextCommand, CommandMessage* reply, bool& isStep);
|
||||
|
||||
void checkTimeout();
|
||||
void checkTimeout();
|
||||
};
|
||||
|
||||
#endif /* FSFW_TMTCSERVICES_COMMANDINGSERVICEBASE_H_ */
|
||||
|
@ -12,28 +12,28 @@ object_id_t PusServiceBase::packetSource = 0;
|
||||
object_id_t PusServiceBase::packetDestination = 0;
|
||||
|
||||
PusServiceBase::PusServiceBase(object_id_t setObjectId, uint16_t setApid,
|
||||
uint8_t setServiceId) :
|
||||
SystemObject(setObjectId), apid(setApid), serviceId(setServiceId) {
|
||||
requestQueue = QueueFactory::instance()->
|
||||
createMessageQueue(PUS_SERVICE_MAX_RECEPTION);
|
||||
uint8_t setServiceId):
|
||||
SystemObject(setObjectId), apid(setApid), serviceId(setServiceId) {
|
||||
requestQueue = QueueFactory::instance()->
|
||||
createMessageQueue(PUS_SERVICE_MAX_RECEPTION);
|
||||
}
|
||||
|
||||
PusServiceBase::~PusServiceBase() {
|
||||
QueueFactory::instance()->deleteMessageQueue(requestQueue);
|
||||
QueueFactory::instance()->deleteMessageQueue(requestQueue);
|
||||
}
|
||||
|
||||
ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
|
||||
handleRequestQueue();
|
||||
ReturnValue_t result = this->performService();
|
||||
if (result != RETURN_OK) {
|
||||
handleRequestQueue();
|
||||
ReturnValue_t result = this->performService();
|
||||
if (result != RETURN_OK) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PusService " << (uint16_t) this->serviceId
|
||||
<< ": performService returned with " << (int16_t) result
|
||||
<< std::endl;
|
||||
sif::error << "PusService " << (uint16_t) this->serviceId
|
||||
<< ": performService returned with " << (int16_t) result
|
||||
<< std::endl;
|
||||
#endif
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle) {
|
||||
@ -41,88 +41,88 @@ void PusServiceBase::setTaskIF(PeriodicTaskIF* taskHandle) {
|
||||
}
|
||||
|
||||
void PusServiceBase::handleRequestQueue() {
|
||||
TmTcMessage message;
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) {
|
||||
ReturnValue_t status = this->requestQueue->receiveMessage(&message);
|
||||
// if(status != MessageQueueIF::EMPTY) {
|
||||
TmTcMessage message;
|
||||
ReturnValue_t result = RETURN_FAILED;
|
||||
for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) {
|
||||
ReturnValue_t status = this->requestQueue->receiveMessage(&message);
|
||||
// if(status != MessageQueueIF::EMPTY) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
// sif::debug << "PusServiceBase::performOperation: Receiving from "
|
||||
// << "MQ ID: " << std::hex << "0x" << std::setw(8)
|
||||
// << std::setfill('0') << this->requestQueue->getId()
|
||||
// << std::dec << " returned: " << status << std::setfill(' ')
|
||||
// << std::endl;
|
||||
// sif::debug << "PusServiceBase::performOperation: Receiving from "
|
||||
// << "MQ ID: " << std::hex << "0x" << std::setw(8)
|
||||
// << std::setfill('0') << this->requestQueue->getId()
|
||||
// << std::dec << " returned: " << status << std::setfill(' ')
|
||||
// << std::endl;
|
||||
#endif
|
||||
// }
|
||||
// }
|
||||
|
||||
if (status == RETURN_OK) {
|
||||
this->currentPacket.setStoreAddress(message.getStorageId());
|
||||
//info << "Service " << (uint16_t) this->serviceId <<
|
||||
// ": new packet!" << std::endl;
|
||||
if (status == RETURN_OK) {
|
||||
this->currentPacket.setStoreAddress(message.getStorageId(), ¤tPacket);
|
||||
//info << "Service " << (uint16_t) this->serviceId <<
|
||||
// ": new packet!" << std::endl;
|
||||
|
||||
result = this->handleRequest(currentPacket.getSubService());
|
||||
result = this->handleRequest(currentPacket.getSubService());
|
||||
|
||||
// debug << "Service " << (uint16_t)this->serviceId <<
|
||||
// ": handleRequest returned: " << (int)return_code << std::endl;
|
||||
if (result == RETURN_OK) {
|
||||
this->verifyReporter.sendSuccessReport(
|
||||
tc_verification::COMPLETION_SUCCESS, &this->currentPacket);
|
||||
}
|
||||
else {
|
||||
this->verifyReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE, &this->currentPacket,
|
||||
result, 0, errorParameter1, errorParameter2);
|
||||
}
|
||||
this->currentPacket.deletePacket();
|
||||
errorParameter1 = 0;
|
||||
errorParameter2 = 0;
|
||||
}
|
||||
else if (status == MessageQueueIF::EMPTY) {
|
||||
status = RETURN_OK;
|
||||
// debug << "PusService " << (uint16_t)this->serviceId <<
|
||||
// ": no new packet." << std::endl;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// debug << "Service " << (uint16_t)this->serviceId <<
|
||||
// ": handleRequest returned: " << (int)return_code << std::endl;
|
||||
if (result == RETURN_OK) {
|
||||
this->verifyReporter.sendSuccessReport(
|
||||
tc_verification::COMPLETION_SUCCESS, &this->currentPacket);
|
||||
}
|
||||
else {
|
||||
this->verifyReporter.sendFailureReport(
|
||||
tc_verification::COMPLETION_FAILURE, &this->currentPacket,
|
||||
result, 0, errorParameter1, errorParameter2);
|
||||
}
|
||||
this->currentPacket.deletePacket();
|
||||
errorParameter1 = 0;
|
||||
errorParameter2 = 0;
|
||||
}
|
||||
else if (status == MessageQueueIF::EMPTY) {
|
||||
status = RETURN_OK;
|
||||
// debug << "PusService " << (uint16_t)this->serviceId <<
|
||||
// ": no new packet." << std::endl;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PusServiceBase::performOperation: Service "
|
||||
<< this->serviceId << ": Error receiving packet. Code: "
|
||||
<< std::hex << status << std::dec << std::endl;
|
||||
sif::error << "PusServiceBase::performOperation: Service "
|
||||
<< this->serviceId << ": Error receiving packet. Code: "
|
||||
<< std::hex << status << std::dec << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t PusServiceBase::getIdentifier() {
|
||||
return this->serviceId;
|
||||
return this->serviceId;
|
||||
}
|
||||
|
||||
MessageQueueId_t PusServiceBase::getRequestQueue() {
|
||||
return this->requestQueue->getId();
|
||||
return this->requestQueue->getId();
|
||||
}
|
||||
|
||||
ReturnValue_t PusServiceBase::initialize() {
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
AcceptsTelemetryIF* destService = ObjectManager::instance()->get<AcceptsTelemetryIF>(
|
||||
packetDestination);
|
||||
PUSDistributorIF* distributor = ObjectManager::instance()->get<PUSDistributorIF>(
|
||||
packetSource);
|
||||
if (destService == nullptr or distributor == nullptr) {
|
||||
ReturnValue_t result = SystemObject::initialize();
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
AcceptsTelemetryIF* destService = ObjectManager::instance()->get<AcceptsTelemetryIF>(
|
||||
packetDestination);
|
||||
PUSDistributorIF* distributor = ObjectManager::instance()->get<PUSDistributorIF>(
|
||||
packetSource);
|
||||
if (destService == nullptr or distributor == nullptr) {
|
||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
||||
sif::error << "PusServiceBase::PusServiceBase: Service "
|
||||
<< this->serviceId << ": Configuration error. Make sure "
|
||||
<< "packetSource and packetDestination are defined correctly"
|
||||
<< std::endl;
|
||||
sif::error << "PusServiceBase::PusServiceBase: Service "
|
||||
<< this->serviceId << ": Configuration error. Make sure "
|
||||
<< "packetSource and packetDestination are defined correctly"
|
||||
<< std::endl;
|
||||
#endif
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
this->requestQueue->setDefaultDestination(
|
||||
destService->getReportReceptionQueue());
|
||||
distributor->registerService(this);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||
}
|
||||
this->requestQueue->setDefaultDestination(
|
||||
destService->getReportReceptionQueue());
|
||||
distributor->registerService(this);
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t PusServiceBase::initializeAfterTaskCreation() {
|
||||
|
@ -35,126 +35,126 @@ void setStaticFrameworkObjectIds();
|
||||
* @ingroup pus_services
|
||||
*/
|
||||
class PusServiceBase : public ExecutableObjectIF,
|
||||
public AcceptsTelecommandsIF,
|
||||
public SystemObject,
|
||||
public HasReturnvaluesIF {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public AcceptsTelecommandsIF,
|
||||
public SystemObject,
|
||||
public HasReturnvaluesIF {
|
||||
friend void (Factory::setStaticFrameworkObjectIds)();
|
||||
public:
|
||||
/**
|
||||
* @brief The passed values are set, but inter-object initialization is
|
||||
* done in the initialize method.
|
||||
* @param setObjectId
|
||||
* The system object identifier of this Service instance.
|
||||
* @param setApid
|
||||
* The APID the Service is instantiated for.
|
||||
* @param setServiceId
|
||||
* The Service Identifier as specified in ECSS PUS.
|
||||
*/
|
||||
PusServiceBase( object_id_t setObjectId, uint16_t setApid,
|
||||
uint8_t setServiceId);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~PusServiceBase();
|
||||
/**
|
||||
* @brief The handleRequest method shall handle any kind of Telecommand
|
||||
* Request immediately.
|
||||
* @details
|
||||
* Implemetations can take the Telecommand in currentPacket and perform
|
||||
* any kind of operation.
|
||||
* They may send additional "Start Success (1,3)" messages with the
|
||||
* verifyReporter, but Completion Success or Failure Reports are generated
|
||||
* automatically after execution of this method.
|
||||
*
|
||||
* If a Telecommand can not be executed within one call cycle,
|
||||
* this Base class is not the right parent.
|
||||
*
|
||||
* The child class may add additional error information by setting
|
||||
* #errorParameters which aren attached to the generated verification
|
||||
* message.
|
||||
*
|
||||
* Subservice checking should be implemented in this method.
|
||||
*
|
||||
* @return The returned status_code is directly taken as main error code
|
||||
* in the Verification Report.
|
||||
* On success, RETURN_OK shall be returned.
|
||||
*/
|
||||
virtual ReturnValue_t handleRequest(uint8_t subservice) = 0;
|
||||
/**
|
||||
* In performService, implementations can handle periodic,
|
||||
* non-TC-triggered activities.
|
||||
* The performService method is always called.
|
||||
* @return Currently, everything other that RETURN_OK only triggers
|
||||
* diagnostic output.
|
||||
*/
|
||||
virtual ReturnValue_t performService() = 0;
|
||||
/**
|
||||
* This method implements the typical activity of a simple PUS Service.
|
||||
* It checks for new requests, and, if found, calls handleRequest, sends
|
||||
* completion verification messages and deletes
|
||||
* the TC requests afterwards.
|
||||
* performService is always executed afterwards.
|
||||
* @return @c RETURN_OK if the periodic performService was successful.
|
||||
* @c RETURN_FAILED else.
|
||||
*/
|
||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
virtual uint16_t getIdentifier() override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
/**
|
||||
* @brief The passed values are set, but inter-object initialization is
|
||||
* done in the initialize method.
|
||||
* @param setObjectId
|
||||
* The system object identifier of this Service instance.
|
||||
* @param setApid
|
||||
* The APID the Service is instantiated for.
|
||||
* @param setServiceId
|
||||
* The Service Identifier as specified in ECSS PUS.
|
||||
*/
|
||||
PusServiceBase( object_id_t setObjectId, uint16_t setApid,
|
||||
uint8_t setServiceId);
|
||||
/**
|
||||
* The destructor is empty.
|
||||
*/
|
||||
virtual ~PusServiceBase();
|
||||
/**
|
||||
* @brief The handleRequest method shall handle any kind of Telecommand
|
||||
* Request immediately.
|
||||
* @details
|
||||
* Implemetations can take the Telecommand in currentPacket and perform
|
||||
* any kind of operation.
|
||||
* They may send additional "Start Success (1,3)" messages with the
|
||||
* verifyReporter, but Completion Success or Failure Reports are generated
|
||||
* automatically after execution of this method.
|
||||
*
|
||||
* If a Telecommand can not be executed within one call cycle,
|
||||
* this Base class is not the right parent.
|
||||
*
|
||||
* The child class may add additional error information by setting
|
||||
* #errorParameters which aren attached to the generated verification
|
||||
* message.
|
||||
*
|
||||
* Subservice checking should be implemented in this method.
|
||||
*
|
||||
* @return The returned status_code is directly taken as main error code
|
||||
* in the Verification Report.
|
||||
* On success, RETURN_OK shall be returned.
|
||||
*/
|
||||
virtual ReturnValue_t handleRequest(uint8_t subservice) = 0;
|
||||
/**
|
||||
* In performService, implementations can handle periodic,
|
||||
* non-TC-triggered activities.
|
||||
* The performService method is always called.
|
||||
* @return Currently, everything other that RETURN_OK only triggers
|
||||
* diagnostic output.
|
||||
*/
|
||||
virtual ReturnValue_t performService() = 0;
|
||||
/**
|
||||
* This method implements the typical activity of a simple PUS Service.
|
||||
* It checks for new requests, and, if found, calls handleRequest, sends
|
||||
* completion verification messages and deletes
|
||||
* the TC requests afterwards.
|
||||
* performService is always executed afterwards.
|
||||
* @return @c RETURN_OK if the periodic performService was successful.
|
||||
* @c RETURN_FAILED else.
|
||||
*/
|
||||
ReturnValue_t performOperation(uint8_t opCode) override;
|
||||
virtual uint16_t getIdentifier() override;
|
||||
MessageQueueId_t getRequestQueue() override;
|
||||
virtual ReturnValue_t initialize() override;
|
||||
|
||||
virtual void setTaskIF(PeriodicTaskIF* taskHandle) override;
|
||||
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||
virtual void setTaskIF(PeriodicTaskIF* taskHandle) override;
|
||||
virtual ReturnValue_t initializeAfterTaskCreation() override;
|
||||
protected:
|
||||
/**
|
||||
* @brief Handle to the underlying task
|
||||
* @details
|
||||
* Will be set by setTaskIF(), which is called on task creation.
|
||||
*/
|
||||
PeriodicTaskIF* taskHandle = nullptr;
|
||||
/**
|
||||
* The APID of this instance of the Service.
|
||||
*/
|
||||
uint16_t apid;
|
||||
/**
|
||||
* The Service Identifier.
|
||||
*/
|
||||
uint8_t serviceId;
|
||||
/**
|
||||
* One of two error parameters for additional error information.
|
||||
*/
|
||||
uint32_t errorParameter1 = 0;
|
||||
/**
|
||||
* One of two error parameters for additional error information.
|
||||
*/
|
||||
uint32_t errorParameter2 = 0;
|
||||
/**
|
||||
* This is a complete instance of the telecommand reception queue
|
||||
* of the class. It is initialized on construction of the class.
|
||||
*/
|
||||
MessageQueueIF* requestQueue = nullptr;
|
||||
/**
|
||||
* An instance of the VerificationReporter class, that simplifies
|
||||
* sending any kind of verification message to the TC Verification Service.
|
||||
*/
|
||||
VerificationReporter verifyReporter;
|
||||
/**
|
||||
* The current Telecommand to be processed.
|
||||
* It is deleted after handleRequest was executed.
|
||||
*/
|
||||
TcPacketStoredPus currentPacket;
|
||||
/**
|
||||
* @brief Handle to the underlying task
|
||||
* @details
|
||||
* Will be set by setTaskIF(), which is called on task creation.
|
||||
*/
|
||||
PeriodicTaskIF* taskHandle = nullptr;
|
||||
/**
|
||||
* The APID of this instance of the Service.
|
||||
*/
|
||||
uint16_t apid;
|
||||
/**
|
||||
* The Service Identifier.
|
||||
*/
|
||||
uint8_t serviceId;
|
||||
/**
|
||||
* One of two error parameters for additional error information.
|
||||
*/
|
||||
uint32_t errorParameter1 = 0;
|
||||
/**
|
||||
* One of two error parameters for additional error information.
|
||||
*/
|
||||
uint32_t errorParameter2 = 0;
|
||||
/**
|
||||
* This is a complete instance of the telecommand reception queue
|
||||
* of the class. It is initialized on construction of the class.
|
||||
*/
|
||||
MessageQueueIF* requestQueue = nullptr;
|
||||
/**
|
||||
* An instance of the VerificationReporter class, that simplifies
|
||||
* sending any kind of verification message to the TC Verification Service.
|
||||
*/
|
||||
VerificationReporter verifyReporter;
|
||||
/**
|
||||
* The current Telecommand to be processed.
|
||||
* It is deleted after handleRequest was executed.
|
||||
*/
|
||||
TcPacketStoredPus currentPacket;
|
||||
|
||||
static object_id_t packetSource;
|
||||
static object_id_t packetSource;
|
||||
|
||||
static object_id_t packetDestination;
|
||||
static object_id_t packetDestination;
|
||||
private:
|
||||
/**
|
||||
* This constant sets the maximum number of packets accepted per call.
|
||||
* Remember that one packet must be completely handled in one
|
||||
* #handleRequest call.
|
||||
*/
|
||||
static const uint8_t PUS_SERVICE_MAX_RECEPTION = 10;
|
||||
/**
|
||||
* This constant sets the maximum number of packets accepted per call.
|
||||
* Remember that one packet must be completely handled in one
|
||||
* #handleRequest call.
|
||||
*/
|
||||
static const uint8_t PUS_SERVICE_MAX_RECEPTION = 10;
|
||||
|
||||
void handleRequestQueue();
|
||||
void handleRequestQueue();
|
||||
};
|
||||
|
||||
#endif /* FSFW_TMTCSERVICES_PUSSERVICEBASE_H_ */
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "VerificationCodes.h"
|
||||
|
||||
#include "fsfw/ipc/MessageQueueMessage.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketBase.h"
|
||||
#include "fsfw/tmtcpacket/pus/tc/TcPacketPusBase.h"
|
||||
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
|
||||
|
||||
class PusVerificationMessage: public MessageQueueMessage {
|
||||
|
@ -17,7 +17,7 @@ VerificationReporter::VerificationReporter() :
|
||||
VerificationReporter::~VerificationReporter() {}
|
||||
|
||||
void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
||||
TcPacketBase* currentPacket, uint8_t set_step) {
|
||||
TcPacketPusBase* currentPacket, uint8_t set_step) {
|
||||
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
||||
this->initialize();
|
||||
}
|
||||
@ -59,7 +59,7 @@ void VerificationReporter::sendSuccessReport(uint8_t set_report_id,
|
||||
}
|
||||
|
||||
void VerificationReporter::sendFailureReport(uint8_t report_id,
|
||||
TcPacketBase* currentPacket, ReturnValue_t error_code, uint8_t step,
|
||||
TcPacketPusBase* currentPacket, ReturnValue_t error_code, uint8_t step,
|
||||
uint32_t parameter1, uint32_t parameter2) {
|
||||
if (acknowledgeQueue == MessageQueueIF::NO_QUEUE) {
|
||||
this->initialize();
|
||||
|
@ -25,13 +25,13 @@ public:
|
||||
VerificationReporter();
|
||||
virtual ~VerificationReporter();
|
||||
|
||||
void sendSuccessReport( uint8_t set_report_id, TcPacketBase* current_packet,
|
||||
void sendSuccessReport( uint8_t set_report_id, TcPacketPusBase* current_packet,
|
||||
uint8_t set_step = 0 );
|
||||
void sendSuccessReport(uint8_t set_report_id, uint8_t ackFlags,
|
||||
uint16_t tcPacketId, uint16_t tcSequenceControl,
|
||||
uint8_t set_step = 0);
|
||||
|
||||
void sendFailureReport( uint8_t report_id, TcPacketBase* current_packet,
|
||||
void sendFailureReport( uint8_t report_id, TcPacketPusBase* current_packet,
|
||||
ReturnValue_t error_code = 0,
|
||||
uint8_t step = 0, uint32_t parameter1 = 0,
|
||||
uint32_t parameter2 = 0 );
|
||||
|
Reference in New Issue
Block a user
Diamond inheritance.