1
0
forked from fsfw/fsfw

Merge remote-tracking branch 'upstream/master' into mueller_FIFO_static_normal

This commit is contained in:
2020-08-27 20:18:06 +02:00
395 changed files with 3834 additions and 1933 deletions

View File

@ -1,7 +1,7 @@
#ifndef ACCEPTSTELECOMMANDSIF_H_
#define ACCEPTSTELECOMMANDSIF_H_
#include <framework/ipc/MessageQueueSenderIF.h>
#include "../ipc/MessageQueueSenderIF.h"
/**
* @brief This interface is implemented by classes that are sinks for

View File

@ -1,7 +1,7 @@
#ifndef ACCEPTSTELEMETRYIF_H_
#define ACCEPTSTELEMETRYIF_H_
#include <framework/ipc/MessageQueueSenderIF.h>
#include "../ipc/MessageQueueSenderIF.h"
/**
* @brief This interface is implemented by classes that are sinks for
* Telemetry.

View File

@ -1,7 +1,7 @@
#ifndef ACCEPTSVERIFICATIONMESSAGEIF_H_
#define ACCEPTSVERIFICATIONMESSAGEIF_H_
#include <framework/ipc/MessageQueueSenderIF.h>
#include "../ipc/MessageQueueSenderIF.h"
class AcceptsVerifyMessageIF {
public:

View File

@ -1,25 +1,35 @@
#include <framework/tcdistribution/PUSDistributorIF.h>
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
#include <framework/objectmanager/ObjectManagerIF.h>
#include "../tcdistribution/PUSDistributorIF.h"
#include "AcceptsTelemetryIF.h"
#include "../objectmanager/ObjectManagerIF.h"
#include <framework/tmtcservices/CommandingServiceBase.h>
#include <framework/tmtcservices/TmTcMessage.h>
#include <framework/ipc/QueueFactory.h>
#include <framework/tmtcpacket/pus/TcPacketStored.h>
#include <framework/tmtcpacket/pus/TmPacketStored.h>
#include "CommandingServiceBase.h"
#include "TmTcMessage.h"
#include "../ipc/QueueFactory.h"
#include "../tmtcpacket/pus/TcPacketStored.h"
#include "../tmtcpacket/pus/TmPacketStored.h"
object_id_t CommandingServiceBase::defaultPacketSource = objects::NO_OBJECT;
object_id_t CommandingServiceBase::defaultPacketDestination = objects::NO_OBJECT;
CommandingServiceBase::CommandingServiceBase(object_id_t setObjectId,
uint16_t apid, uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeoutSeconds, object_id_t setPacketSource,
object_id_t setPacketDestination, size_t queueDepth) :
uint16_t commandTimeoutSeconds, size_t queueDepth) :
SystemObject(setObjectId), apid(apid), service(service),
timeoutSeconds(commandTimeoutSeconds),
commandMap(numberOfParallelCommands), packetSource(setPacketSource),
packetDestination(setPacketDestination) {
commandMap(numberOfParallelCommands) {
commandQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
requestQueue = QueueFactory::instance()->createMessageQueue(queueDepth);
}
void CommandingServiceBase::setPacketSource(object_id_t packetSource) {
this->packetSource = packetSource;
}
void CommandingServiceBase::setPacketDestination(
object_id_t packetDestination) {
this->packetDestination = packetDestination;
}
CommandingServiceBase::~CommandingServiceBase() {
QueueFactory::instance()->deleteMessageQueue(commandQueue);
@ -52,10 +62,18 @@ ReturnValue_t CommandingServiceBase::initialize() {
return result;
}
if(packetDestination == objects::NO_OBJECT) {
packetDestination = defaultPacketDestination;
}
AcceptsTelemetryIF* packetForwarding =
objectManager->get<AcceptsTelemetryIF>(packetDestination);
if(packetSource == objects::NO_OBJECT) {
packetSource = defaultPacketSource;
}
PUSDistributorIF* distributor = objectManager->get<PUSDistributorIF>(
packetSource);
if (packetForwarding == nullptr or distributor == nullptr) {
sif::error << "CommandingServiceBase::intialize: Packet source or "
"packet destination invalid!" << std::endl;
@ -108,11 +126,11 @@ void CommandingServiceBase::handleCommandMessage(CommandMessage* reply) {
&nextCommand, iter->objectId, &isStep);
/* If the child implementation does not implement special handling for
* rejected replies (RETURN_FAILED 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) {
* 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->command;
}

View File

@ -1,20 +1,24 @@
#ifndef FRAMEWORK_TMTCSERVICES_COMMANDINGSERVICEBASE_H_
#define FRAMEWORK_TMTCSERVICES_COMMANDINGSERVICEBASE_H_
#include <framework/objectmanager/SystemObject.h>
#include <framework/storagemanager/StorageManagerIF.h>
#include <framework/tasks/ExecutableObjectIF.h>
#include <framework/ipc/MessageQueueIF.h>
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
#include "../objectmanager/SystemObject.h"
#include "../storagemanager/StorageManagerIF.h"
#include "../tasks/ExecutableObjectIF.h"
#include "../ipc/MessageQueueIF.h"
#include "AcceptsTelecommandsIF.h"
#include <framework/tmtcservices/VerificationReporter.h>
#include <framework/ipc/CommandMessage.h>
#include <framework/container/FixedMap.h>
#include <framework/container/FIFO.h>
#include <framework/serialize/SerializeIF.h>
#include "VerificationReporter.h"
#include "../ipc/CommandMessage.h"
#include "../container/FixedMap.h"
#include "../container/FIFO.h"
#include "../serialize/SerializeIF.h"
class TcPacketStored;
namespace Factory{
void setStaticFrameworkObjectIds();
}
/**
* @brief This class is the basis for all PUS Services, which have to
* relay Telecommands to software bus.
@ -33,6 +37,7 @@ class CommandingServiceBase: public SystemObject,
public AcceptsTelecommandsIF,
public ExecutableObjectIF,
public HasReturnvaluesIF {
friend void (Factory::setStaticFrameworkObjectIds)();
public:
static const uint8_t INTERFACE_ID = CLASS_ID::COMMAND_SERVICE_BASE;
static const ReturnValue_t EXECUTION_COMPLETE = MAKE_RETURN_CODE(1);
@ -57,10 +62,24 @@ public:
*/
CommandingServiceBase(object_id_t setObjectId, uint16_t apid,
uint8_t service, uint8_t numberOfParallelCommands,
uint16_t commandTimeoutSeconds, object_id_t setPacketSource,
object_id_t setPacketDestination, size_t queueDepth = 20);
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 is the periodically called function.
* Handle request queue for external commands.
@ -68,7 +87,7 @@ public:
* @param opCode is unused here at the moment
* @return RETURN_OK
*/
virtual ReturnValue_t performOperation(uint8_t opCode);
virtual ReturnValue_t performOperation(uint8_t opCode) override;
virtual uint16_t getIdentifier();
@ -89,22 +108,23 @@ public:
*/
virtual MessageQueueId_t getCommandQueue();
virtual ReturnValue_t initialize();
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
* @param task Pointer to the taskIF of this task
*/
virtual void setTaskIF(PeriodicTaskIF* task_);
virtual void setTaskIF(PeriodicTaskIF* task) override;
protected:
/**
* Check the target subservice
* @param subservice[in]
* @return -@c RETURN_OK on success
* -@c INVALID_SUBSERVICE if service is not known
* @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;
@ -117,9 +137,10 @@ protected:
* @param tcDataLen
* @param id MessageQueue ID is stored here
* @param objectId Object ID is extracted and stored here
* @return - @c RETURN_OK on success
* - @c RETURN_FAILED
* - @c CSB or implementation specific return codes
* @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,
@ -138,6 +159,11 @@ protected:
* 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,
@ -160,11 +186,12 @@ protected:
* @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
* 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.
* - @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,
@ -227,9 +254,10 @@ protected:
uint32_t failureParameter1 = 0;
uint32_t failureParameter2 = 0;
object_id_t packetSource;
object_id_t packetDestination;
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,
@ -274,7 +302,6 @@ protected:
void checkAndExecuteFifo(CommandMapIter iter);
private:
/**
* This method handles internal execution of a command,
* once it has been started by @sa{startExecution()} in the request
@ -294,10 +321,13 @@ private:
void handleCommandQueue();
/**
* @brief Handler function for request queue
* @details
* Sequence of request queue handling:
* isValidSubservice -> getMessageQueueAndObject -> startExecution
* Generates Start Success Reports TM[1,3] in subfunction @sa{startExecution()}
* or Start Failure Report TM[1,4] by using the TC Verification Service
* 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();

View File

@ -1,10 +1,10 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tcdistribution/PUSDistributorIF.h>
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
#include <framework/tmtcservices/PusServiceBase.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/tmtcservices/TmTcMessage.h>
#include <framework/ipc/QueueFactory.h>
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../tcdistribution/PUSDistributorIF.h"
#include "AcceptsTelemetryIF.h"
#include "PusServiceBase.h"
#include "PusVerificationReport.h"
#include "TmTcMessage.h"
#include "../ipc/QueueFactory.h"
object_id_t PusServiceBase::packetSource = 0;
object_id_t PusServiceBase::packetDestination = 0;

View File

@ -1,15 +1,15 @@
#ifndef FRAMEWORK_TMTCSERVICES_PUSSERVICEBASE_H_
#define FRAMEWORK_TMTCSERVICES_PUSSERVICEBASE_H_
#include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/objectmanager/SystemObject.h>
#include <framework/returnvalues/HasReturnvaluesIF.h>
#include <framework/tasks/ExecutableObjectIF.h>
#include <framework/tmtcpacket/pus/TcPacketStored.h>
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
#include <framework/tmtcservices/VerificationCodes.h>
#include <framework/tmtcservices/VerificationReporter.h>
#include <framework/ipc/MessageQueueIF.h>
#include "../objectmanager/ObjectManagerIF.h"
#include "../objectmanager/SystemObject.h"
#include "../returnvalues/HasReturnvaluesIF.h"
#include "../tasks/ExecutableObjectIF.h"
#include "../tmtcpacket/pus/TcPacketStored.h"
#include "AcceptsTelecommandsIF.h"
#include "VerificationCodes.h"
#include "VerificationReporter.h"
#include "../ipc/MessageQueueIF.h"
namespace Factory{
void setStaticFrameworkObjectIds();

View File

@ -1,5 +1,5 @@
#include <framework/serialize/SerializeAdapter.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include "../serialize/SerializeAdapter.h"
#include "PusVerificationReport.h"
PusVerificationMessage::PusVerificationMessage() {
}

View File

@ -1,9 +1,9 @@
#ifndef PUSVERIFICATIONREPORT_H_
#define PUSVERIFICATIONREPORT_H_
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/tmtcpacket/pus/TcPacketBase.h>
#include <framework/tmtcservices/VerificationCodes.h>
#include "../ipc/MessageQueueMessage.h"
#include "../tmtcpacket/pus/TcPacketBase.h"
#include "VerificationCodes.h"
class PusVerificationMessage: public MessageQueueMessage {
private:

View File

@ -7,7 +7,7 @@
#ifndef SOURCESEQUENCECOUNTER_H_
#define SOURCESEQUENCECOUNTER_H_
#include <framework/tmtcpacket/SpacePacketBase.h>
#include "../tmtcpacket/SpacePacketBase.h"
class SourceSequenceCounter {
private:

View File

@ -1,211 +1,211 @@
#include <framework/tmtcservices/TmTcBridge.h>
#include <framework/ipc/QueueFactory.h>
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/globalfunctions/arrayprinter.h>
TmTcBridge::TmTcBridge(object_id_t objectId, object_id_t tcDestination,
object_id_t tmStoreId, object_id_t tcStoreId):
SystemObject(objectId),tmStoreId(tmStoreId), tcStoreId(tcStoreId),
tcDestination(tcDestination)
{
tmTcReceptionQueue = QueueFactory::instance()->
createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH);
}
TmTcBridge::~TmTcBridge() {}
ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(
uint8_t sentPacketsPerCycle) {
if(sentPacketsPerCycle <= LIMIT_STORED_DATA_SENT_PER_CYCLE) {
this->sentPacketsPerCycle = sentPacketsPerCycle;
return RETURN_OK;
}
else {
sif::warning << "TmTcBridge::setNumberOfSentPacketsPerCycle: Number of "
<< "packets sent per cycle exceeds limits. "
<< "Keeping default value." << std::endl;
return RETURN_FAILED;
}
}
ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(
uint8_t maxNumberOfPacketsStored) {
if(maxNumberOfPacketsStored <= LIMIT_DOWNLINK_PACKETS_STORED) {
this->maxNumberOfPacketsStored = maxNumberOfPacketsStored;
return RETURN_OK;
}
else {
sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of "
<< "packets stored exceeds limits. "
<< "Keeping default value." << std::endl;
return RETURN_FAILED;
}
}
ReturnValue_t TmTcBridge::initialize() {
tcStore = objectManager->get<StorageManagerIF>(tcStoreId);
if (tcStore == nullptr) {
sif::error << "TmTcBridge::initialize: TC store invalid. Make sure"
"it is created and set up properly." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmStore = objectManager->get<StorageManagerIF>(tmStoreId);
if (tmStore == nullptr) {
sif::error << "TmTcBridge::initialize: TM store invalid. Make sure"
"it is created and set up properly." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelecommandsIF* tcDistributor =
objectManager->get<AcceptsTelecommandsIF>(tcDestination);
if (tcDistributor == nullptr) {
sif::error << "TmTcBridge::initialize: TC Distributor invalid"
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmTcReceptionQueue->setDefaultDestination(tcDistributor->getRequestQueue());
return RETURN_OK;
}
ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) {
ReturnValue_t result;
result = handleTc();
if(result != RETURN_OK) {
sif::debug << "TmTcBridge::performOperation: "
<< "Error handling TCs" << std::endl;
}
result = handleTm();
if (result != RETURN_OK) {
sif::debug << "TmTcBridge::performOperation: "
<< "Error handling TMs" << std::endl;
}
return result;
}
ReturnValue_t TmTcBridge::handleTc() {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t TmTcBridge::handleTm() {
ReturnValue_t result = handleTmQueue();
if(result != RETURN_OK) {
sif::warning << "TmTcBridge: Reading TM Queue failed" << std::endl;
return RETURN_FAILED;
}
if(tmStored and communicationLinkUp) {
result = handleStoredTm();
}
return result;
}
ReturnValue_t TmTcBridge::handleTmQueue() {
TmTcMessage message;
#include "TmTcBridge.h"
#include "../ipc/QueueFactory.h"
#include "AcceptsTelecommandsIF.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "../globalfunctions/arrayprinter.h"
TmTcBridge::TmTcBridge(object_id_t objectId, object_id_t tcDestination,
object_id_t tmStoreId, object_id_t tcStoreId):
SystemObject(objectId),tmStoreId(tmStoreId), tcStoreId(tcStoreId),
tcDestination(tcDestination)
{
tmTcReceptionQueue = QueueFactory::instance()->
createMessageQueue(TMTC_RECEPTION_QUEUE_DEPTH);
}
TmTcBridge::~TmTcBridge() {}
ReturnValue_t TmTcBridge::setNumberOfSentPacketsPerCycle(
uint8_t sentPacketsPerCycle) {
if(sentPacketsPerCycle <= LIMIT_STORED_DATA_SENT_PER_CYCLE) {
this->sentPacketsPerCycle = sentPacketsPerCycle;
return RETURN_OK;
}
else {
sif::warning << "TmTcBridge::setNumberOfSentPacketsPerCycle: Number of "
<< "packets sent per cycle exceeds limits. "
<< "Keeping default value." << std::endl;
return RETURN_FAILED;
}
}
ReturnValue_t TmTcBridge::setMaxNumberOfPacketsStored(
uint8_t maxNumberOfPacketsStored) {
if(maxNumberOfPacketsStored <= LIMIT_DOWNLINK_PACKETS_STORED) {
this->maxNumberOfPacketsStored = maxNumberOfPacketsStored;
return RETURN_OK;
}
else {
sif::warning << "TmTcBridge::setMaxNumberOfPacketsStored: Number of "
<< "packets stored exceeds limits. "
<< "Keeping default value." << std::endl;
return RETURN_FAILED;
}
}
ReturnValue_t TmTcBridge::initialize() {
tcStore = objectManager->get<StorageManagerIF>(tcStoreId);
if (tcStore == nullptr) {
sif::error << "TmTcBridge::initialize: TC store invalid. Make sure"
"it is created and set up properly." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmStore = objectManager->get<StorageManagerIF>(tmStoreId);
if (tmStore == nullptr) {
sif::error << "TmTcBridge::initialize: TM store invalid. Make sure"
"it is created and set up properly." << std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
AcceptsTelecommandsIF* tcDistributor =
objectManager->get<AcceptsTelecommandsIF>(tcDestination);
if (tcDistributor == nullptr) {
sif::error << "TmTcBridge::initialize: TC Distributor invalid"
<< std::endl;
return ObjectManagerIF::CHILD_INIT_FAILED;
}
tmTcReceptionQueue->setDefaultDestination(tcDistributor->getRequestQueue());
return RETURN_OK;
}
ReturnValue_t TmTcBridge::performOperation(uint8_t operationCode) {
ReturnValue_t result;
result = handleTc();
if(result != RETURN_OK) {
sif::debug << "TmTcBridge::performOperation: "
<< "Error handling TCs" << std::endl;
}
result = handleTm();
if (result != RETURN_OK) {
sif::debug << "TmTcBridge::performOperation: "
<< "Error handling TMs" << std::endl;
}
return result;
}
ReturnValue_t TmTcBridge::handleTc() {
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t TmTcBridge::handleTm() {
ReturnValue_t result = handleTmQueue();
if(result != RETURN_OK) {
sif::warning << "TmTcBridge: Reading TM Queue failed" << std::endl;
return RETURN_FAILED;
}
if(tmStored and communicationLinkUp) {
result = handleStoredTm();
}
return result;
}
ReturnValue_t TmTcBridge::handleTmQueue() {
TmTcMessage message;
const uint8_t* data = nullptr;
size_t size = 0;
for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message);
result == RETURN_OK; result = tmTcReceptionQueue->receiveMessage(&message))
{
if(communicationLinkUp == false) {
result = storeDownlinkData(&message);
return result;
}
result = tmStore->getData(message.getStorageId(), &data, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {
continue;
}
result = sendTm(data, size);
if (result != RETURN_OK) {
sif::warning << "TmTcBridge: Could not send TM packet" << std::endl;
tmStore->deleteData(message.getStorageId());
return result;
}
tmStore->deleteData(message.getStorageId());
}
return RETURN_OK;
}
ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) {
store_address_t storeId = 0;
if(tmFifo.full()) {
sif::error << "TmTcBridge::storeDownlinkData: TM downlink max. number "
<< "of stored packet IDs reached! "
<< "Overwriting old data" << std::endl;
tmFifo.retrieve(&storeId);
tmStore->deleteData(storeId);
}
storeId = message->getStorageId();
tmFifo.insert(storeId);
tmStored = true;
return RETURN_OK;
}
ReturnValue_t TmTcBridge::handleStoredTm() {
uint8_t counter = 0;
ReturnValue_t result = RETURN_OK;
while(not tmFifo.empty() and counter < sentPacketsPerCycle) {
//info << "TMTC Bridge: Sending stored TM data. There are "
// << (int) fifo.size() << " left to send\r\n" << std::flush;
store_address_t storeId;
for (ReturnValue_t result = tmTcReceptionQueue->receiveMessage(&message);
result == RETURN_OK; result = tmTcReceptionQueue->receiveMessage(&message))
{
if(communicationLinkUp == false) {
result = storeDownlinkData(&message);
return result;
}
result = tmStore->getData(message.getStorageId(), &data, &size);
if (result != HasReturnvaluesIF::RETURN_OK) {
continue;
}
result = sendTm(data, size);
if (result != RETURN_OK) {
sif::warning << "TmTcBridge: Could not send TM packet" << std::endl;
tmStore->deleteData(message.getStorageId());
return result;
}
tmStore->deleteData(message.getStorageId());
}
return RETURN_OK;
}
ReturnValue_t TmTcBridge::storeDownlinkData(TmTcMessage *message) {
store_address_t storeId = 0;
if(tmFifo.full()) {
sif::error << "TmTcBridge::storeDownlinkData: TM downlink max. number "
<< "of stored packet IDs reached! "
<< "Overwriting old data" << std::endl;
tmFifo.retrieve(&storeId);
tmStore->deleteData(storeId);
}
storeId = message->getStorageId();
tmFifo.insert(storeId);
tmStored = true;
return RETURN_OK;
}
ReturnValue_t TmTcBridge::handleStoredTm() {
uint8_t counter = 0;
ReturnValue_t result = RETURN_OK;
while(not tmFifo.empty() and counter < sentPacketsPerCycle) {
//info << "TMTC Bridge: Sending stored TM data. There are "
// << (int) fifo.size() << " left to send\r\n" << std::flush;
store_address_t storeId;
const uint8_t* data = nullptr;
size_t size = 0;
tmFifo.retrieve(&storeId);
result = tmStore->getData(storeId, &data, &size);
sendTm(data,size);
if(result != RETURN_OK) {
sif::error << "TMTC Bridge: Could not send stored downlink data"
<< std::endl;
result = RETURN_FAILED;
}
counter ++;
if(tmFifo.empty()) {
tmStored = false;
}
tmStore->deleteData(storeId);
}
return result;
}
void TmTcBridge::registerCommConnect() {
if(not communicationLinkUp) {
//info << "TMTC Bridge: Registered Comm Link Connect" << std::endl;
communicationLinkUp = true;
}
}
void TmTcBridge::registerCommDisconnect() {
//info << "TMTC Bridge: Registered Comm Link Disconnect" << std::endl;
if(communicationLinkUp) {
communicationLinkUp = false;
}
}
MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) {
return tmTcReceptionQueue->getId();
}
void TmTcBridge::printData(uint8_t * data, size_t dataLen) {
arrayprinter::print(data, dataLen);
}
uint16_t TmTcBridge::getIdentifier() {
// This is no PUS service, so we just return 0
return 0;
}
MessageQueueId_t TmTcBridge::getRequestQueue() {
// Default implementation: Relay TC messages to TC distributor directly.
return tmTcReceptionQueue->getDefaultDestination();
}
tmFifo.retrieve(&storeId);
result = tmStore->getData(storeId, &data, &size);
sendTm(data,size);
if(result != RETURN_OK) {
sif::error << "TMTC Bridge: Could not send stored downlink data"
<< std::endl;
result = RETURN_FAILED;
}
counter ++;
if(tmFifo.empty()) {
tmStored = false;
}
tmStore->deleteData(storeId);
}
return result;
}
void TmTcBridge::registerCommConnect() {
if(not communicationLinkUp) {
//info << "TMTC Bridge: Registered Comm Link Connect" << std::endl;
communicationLinkUp = true;
}
}
void TmTcBridge::registerCommDisconnect() {
//info << "TMTC Bridge: Registered Comm Link Disconnect" << std::endl;
if(communicationLinkUp) {
communicationLinkUp = false;
}
}
MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) {
return tmTcReceptionQueue->getId();
}
void TmTcBridge::printData(uint8_t * data, size_t dataLen) {
arrayprinter::print(data, dataLen);
}
uint16_t TmTcBridge::getIdentifier() {
// This is no PUS service, so we just return 0
return 0;
}
MessageQueueId_t TmTcBridge::getRequestQueue() {
// Default implementation: Relay TC messages to TC distributor directly.
return tmTcReceptionQueue->getDefaultDestination();
}

View File

@ -1,154 +1,154 @@
#ifndef FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
#define FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
#include <framework/objectmanager/SystemObject.h>
#include <framework/tmtcservices/AcceptsTelemetryIF.h>
#include <framework/tasks/ExecutableObjectIF.h>
#include <framework/ipc/MessageQueueIF.h>
#include <framework/storagemanager/StorageManagerIF.h>
#include <framework/tmtcservices/AcceptsTelecommandsIF.h>
#include <framework/container/FIFO.h>
#include <framework/tmtcservices/TmTcMessage.h>
class TmTcBridge : public AcceptsTelemetryIF,
public AcceptsTelecommandsIF,
public ExecutableObjectIF,
public HasReturnvaluesIF,
public SystemObject {
public:
static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20;
static constexpr uint8_t LIMIT_STORED_DATA_SENT_PER_CYCLE = 15;
static constexpr uint8_t LIMIT_DOWNLINK_PACKETS_STORED = 20;
static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5;
static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10;
TmTcBridge(object_id_t objectId, object_id_t tcDestination,
object_id_t tmStoreId, object_id_t tcStoreId);
virtual ~TmTcBridge();
/**
* Set number of packets sent per performOperation().Please note that this
* value must be smaller than MAX_STORED_DATA_SENT_PER_CYCLE
* @param sentPacketsPerCycle
* @return -@c RETURN_OK if value was set successfully
* -@c RETURN_FAILED otherwise, stored value stays the same
*/
ReturnValue_t setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle);
/**
* Set number of packets sent per performOperation().Please note that this
* value must be smaller than MAX_DOWNLINK_PACKETS_STORED
* @param sentPacketsPerCycle
* @return -@c RETURN_OK if value was set successfully
* -@c RETURN_FAILED otherwise, stored value stays the same
*/
ReturnValue_t setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored);
virtual void registerCommConnect();
virtual void registerCommDisconnect();
/**
* Initializes necessary FSFW components for the TMTC Bridge
* @return
*/
virtual ReturnValue_t initialize() override;
/**
* @brief Handles TMTC reception
*/
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
/** AcceptsTelemetryIF override */
virtual MessageQueueId_t getReportReceptionQueue(
uint8_t virtualChannel = 0) override;
/** AcceptsTelecommandsIF override */
virtual uint16_t getIdentifier() override;
virtual MessageQueueId_t getRequestQueue() override;
protected:
//! Cached for initialize function.
object_id_t tmStoreId = objects::NO_OBJECT;
object_id_t tcStoreId = objects::NO_OBJECT;
object_id_t tcDestination = objects::NO_OBJECT;
//! Used to send and receive TMTC messages.
//! The TmTcMessage class is used to transport messages between tasks.
MessageQueueIF* tmTcReceptionQueue = nullptr;
StorageManagerIF* tmStore = nullptr;
StorageManagerIF* tcStore = nullptr;
//! Used to specify whether communication link is up. Will be true
//! by default, so telemetry will be handled immediately.
bool communicationLinkUp = true;
bool tmStored = false;
/**
* @brief Handle TC reception
* @details
* Default implementation provided, but is empty.
* In most cases, TC reception will be handled in a separate task anyway.
* @return
*/
virtual ReturnValue_t handleTc();
/**
* Handle Telemetry. Default implementation provided.
* Calls sendTm()
* @return
*/
virtual ReturnValue_t handleTm();
/**
* Read the TM Queue and send TM if necessary.
* Default implementation provided
* @return
*/
virtual ReturnValue_t handleTmQueue();
/**
* Send stored data if communication link is active
* @return
*/
virtual ReturnValue_t handleStoredTm();
/**
* Implemented by child class. Perform sending of Telemetry by implementing
* communication drivers or wrappers, e.g. serial communication or a socket
* call.
* @param data
* @param dataLen
* @return
*/
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) = 0;
/**
* Store data to be sent later if communication link is not up.
* @param message
* @return
*/
virtual ReturnValue_t storeDownlinkData(TmTcMessage * message);
/**
* Print data as hexidecimal array
* @param data
* @param dataLen
*/
void printData(uint8_t * data, size_t dataLen);
/**
* This fifo can be used to store downlink data
* which can not be sent at the moment.
*/
FIFO<store_address_t, LIMIT_DOWNLINK_PACKETS_STORED> tmFifo;
uint8_t sentPacketsPerCycle = DEFAULT_STORED_DATA_SENT_PER_CYCLE;
uint8_t maxNumberOfPacketsStored = DEFAULT_DOWNLINK_PACKETS_STORED;
};
#endif /* FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ */
#ifndef FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
#define FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_
#include "../objectmanager/SystemObject.h"
#include "AcceptsTelemetryIF.h"
#include "../tasks/ExecutableObjectIF.h"
#include "../ipc/MessageQueueIF.h"
#include "../storagemanager/StorageManagerIF.h"
#include "AcceptsTelecommandsIF.h"
#include "../container/FIFO.h"
#include "TmTcMessage.h"
class TmTcBridge : public AcceptsTelemetryIF,
public AcceptsTelecommandsIF,
public ExecutableObjectIF,
public HasReturnvaluesIF,
public SystemObject {
public:
static constexpr uint8_t TMTC_RECEPTION_QUEUE_DEPTH = 20;
static constexpr uint8_t LIMIT_STORED_DATA_SENT_PER_CYCLE = 15;
static constexpr uint8_t LIMIT_DOWNLINK_PACKETS_STORED = 20;
static constexpr uint8_t DEFAULT_STORED_DATA_SENT_PER_CYCLE = 5;
static constexpr uint8_t DEFAULT_DOWNLINK_PACKETS_STORED = 10;
TmTcBridge(object_id_t objectId, object_id_t tcDestination,
object_id_t tmStoreId, object_id_t tcStoreId);
virtual ~TmTcBridge();
/**
* Set number of packets sent per performOperation().Please note that this
* value must be smaller than MAX_STORED_DATA_SENT_PER_CYCLE
* @param sentPacketsPerCycle
* @return -@c RETURN_OK if value was set successfully
* -@c RETURN_FAILED otherwise, stored value stays the same
*/
ReturnValue_t setNumberOfSentPacketsPerCycle(uint8_t sentPacketsPerCycle);
/**
* Set number of packets sent per performOperation().Please note that this
* value must be smaller than MAX_DOWNLINK_PACKETS_STORED
* @param sentPacketsPerCycle
* @return -@c RETURN_OK if value was set successfully
* -@c RETURN_FAILED otherwise, stored value stays the same
*/
ReturnValue_t setMaxNumberOfPacketsStored(uint8_t maxNumberOfPacketsStored);
virtual void registerCommConnect();
virtual void registerCommDisconnect();
/**
* Initializes necessary FSFW components for the TMTC Bridge
* @return
*/
virtual ReturnValue_t initialize() override;
/**
* @brief Handles TMTC reception
*/
virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
/** AcceptsTelemetryIF override */
virtual MessageQueueId_t getReportReceptionQueue(
uint8_t virtualChannel = 0) override;
/** AcceptsTelecommandsIF override */
virtual uint16_t getIdentifier() override;
virtual MessageQueueId_t getRequestQueue() override;
protected:
//! Cached for initialize function.
object_id_t tmStoreId = objects::NO_OBJECT;
object_id_t tcStoreId = objects::NO_OBJECT;
object_id_t tcDestination = objects::NO_OBJECT;
//! Used to send and receive TMTC messages.
//! The TmTcMessage class is used to transport messages between tasks.
MessageQueueIF* tmTcReceptionQueue = nullptr;
StorageManagerIF* tmStore = nullptr;
StorageManagerIF* tcStore = nullptr;
//! Used to specify whether communication link is up. Will be true
//! by default, so telemetry will be handled immediately.
bool communicationLinkUp = true;
bool tmStored = false;
/**
* @brief Handle TC reception
* @details
* Default implementation provided, but is empty.
* In most cases, TC reception will be handled in a separate task anyway.
* @return
*/
virtual ReturnValue_t handleTc();
/**
* Handle Telemetry. Default implementation provided.
* Calls sendTm()
* @return
*/
virtual ReturnValue_t handleTm();
/**
* Read the TM Queue and send TM if necessary.
* Default implementation provided
* @return
*/
virtual ReturnValue_t handleTmQueue();
/**
* Send stored data if communication link is active
* @return
*/
virtual ReturnValue_t handleStoredTm();
/**
* Implemented by child class. Perform sending of Telemetry by implementing
* communication drivers or wrappers, e.g. serial communication or a socket
* call.
* @param data
* @param dataLen
* @return
*/
virtual ReturnValue_t sendTm(const uint8_t * data, size_t dataLen) = 0;
/**
* Store data to be sent later if communication link is not up.
* @param message
* @return
*/
virtual ReturnValue_t storeDownlinkData(TmTcMessage * message);
/**
* Print data as hexidecimal array
* @param data
* @param dataLen
*/
void printData(uint8_t * data, size_t dataLen);
/**
* This fifo can be used to store downlink data
* which can not be sent at the moment.
*/
FIFO<store_address_t, LIMIT_DOWNLINK_PACKETS_STORED> tmFifo;
uint8_t sentPacketsPerCycle = DEFAULT_STORED_DATA_SENT_PER_CYCLE;
uint8_t maxNumberOfPacketsStored = DEFAULT_DOWNLINK_PACKETS_STORED;
};
#endif /* FRAMEWORK_TMTCSERVICES_TMTCBRIDGE_H_ */

View File

@ -1,4 +1,4 @@
#include <framework/tmtcservices/TmTcMessage.h>
#include "TmTcMessage.h"
#include <string.h>

View File

@ -1,8 +1,8 @@
#ifndef TMTCMESSAGE_H_
#define TMTCMESSAGE_H_
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/storagemanager/StorageManagerIF.h>
#include "../ipc/MessageQueueMessage.h"
#include "../storagemanager/StorageManagerIF.h"
/**
* @brief This message class is used to pass Telecommand and Telemetry
* packets between tasks.

View File

@ -1,7 +1,7 @@
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <framework/tmtcservices/AcceptsVerifyMessageIF.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include <framework/tmtcservices/VerificationReporter.h>
#include "../serviceinterface/ServiceInterfaceStream.h"
#include "AcceptsVerifyMessageIF.h"
#include "PusVerificationReport.h"
#include "VerificationReporter.h"
object_id_t VerificationReporter::messageReceiver = 0;

View File

@ -1,8 +1,8 @@
#ifndef VERIFICATIONREPORTER_H_
#define VERIFICATIONREPORTER_H_
#include <framework/objectmanager/ObjectManagerIF.h>
#include <framework/tmtcservices/PusVerificationReport.h>
#include "../objectmanager/ObjectManagerIF.h"
#include "PusVerificationReport.h"
namespace Factory{
void setStaticFrameworkObjectIds();