Update from upstream #94

Merged
meierj merged 12 commits from mueller/update-from-upstream into develop 2022-05-25 15:24:19 +02:00
8 changed files with 101 additions and 40 deletions

View File

@ -27,6 +27,7 @@ enum : uint8_t {
PUS_SERVICE_6 = 86, PUS_SERVICE_6 = 86,
PUS_SERVICE_8 = 88, PUS_SERVICE_8 = 88,
PUS_SERVICE_9 = 89, PUS_SERVICE_9 = 89,
PUS_SERVICE_11 = 91,
PUS_SERVICE_17 = 97, PUS_SERVICE_17 = 97,
PUS_SERVICE_23 = 103, PUS_SERVICE_23 = 103,
MGM_LIS3MDL = 106, MGM_LIS3MDL = 106,

View File

@ -122,7 +122,6 @@ TcpTmTcServer::~TcpTmTcServer() { closeSocket(listenerTcpSocket); }
} }
connSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen); connSocket = accept(listenerTcpSocket, &clientSockAddr, &connectorSockAddrLen);
// connSocket = accept(listenerTcpSocket, nullptr, nullptr);
if (connSocket == INVALID_SOCKET) { if (connSocket == INVALID_SOCKET) {
handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500); handleError(Protocol::TCP, ErrorSources::ACCEPT_CALL, 500);

View File

@ -44,8 +44,15 @@ class Service11TelecommandScheduling final : public PusServiceBase {
static constexpr ReturnValue_t INVALID_RELATIVE_TIME = static constexpr ReturnValue_t INVALID_RELATIVE_TIME =
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3); HasReturnvaluesIF::makeReturnCode(CLASS_ID, 3);
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::PUS_SERVICE_11;
//! [EXPORT] : [COMMENT] Deletion of a TC from the map failed.
//! P1: First 32 bit of request ID, P2. Last 32 bit of Request ID
static constexpr Event TC_DELETION_FAILED = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
// The types of PUS-11 subservices // The types of PUS-11 subservices
enum [[maybe_unused]] Subservice : uint8_t{ENABLE_SCHEDULING = 1, enum Subservice : uint8_t {
ENABLE_SCHEDULING = 1,
DISABLE_SCHEDULING = 2, DISABLE_SCHEDULING = 2,
RESET_SCHEDULING = 3, RESET_SCHEDULING = 3,
INSERT_ACTIVITY = 4, INSERT_ACTIVITY = 4,
@ -55,7 +62,8 @@ class Service11TelecommandScheduling final : public PusServiceBase {
FILTER_TIMESHIFT_ACTIVITY = 8, FILTER_TIMESHIFT_ACTIVITY = 8,
DETAIL_REPORT = 9, DETAIL_REPORT = 9,
TIMEBASE_SCHEDULE_DETAIL_REPORT = 10, TIMEBASE_SCHEDULE_DETAIL_REPORT = 10,
TIMESHIFT_ALL_SCHEDULE_ACTIVITIES = 15}; TIMESHIFT_ALL_SCHEDULE_ACTIVITIES = 15
};
// The types of time windows for TC[11,6] and TC[11,8], as defined in ECSS-E-ST-70-41C, // The types of time windows for TC[11,6] and TC[11,8], as defined in ECSS-E-ST-70-41C,
// requirement 8.11.3c (p. 507) // requirement 8.11.3c (p. 507)
@ -73,6 +81,9 @@ class Service11TelecommandScheduling final : public PusServiceBase {
~Service11TelecommandScheduling() override; ~Service11TelecommandScheduling() override;
void enableExpiredTcDeletion();
void disableExpiredTcDeletion();
/** PusServiceBase overrides */ /** PusServiceBase overrides */
ReturnValue_t handleRequest(uint8_t subservice) override; ReturnValue_t handleRequest(uint8_t subservice) override;
ReturnValue_t performService() override; ReturnValue_t performService() override;
@ -90,6 +101,11 @@ class Service11TelecommandScheduling final : public PusServiceBase {
// minimum release time offset to insert into schedule // minimum release time offset to insert into schedule
const uint16_t RELEASE_TIME_MARGIN_SECONDS = 5; const uint16_t RELEASE_TIME_MARGIN_SECONDS = 5;
/**
* By default, the scheduling will be disabled. This is a standard requirement
*/
bool schedulingEnabled = false;
bool deleteExpiredTcWhenDisabled = true;
bool debugMode = false; bool debugMode = false;
StorageManagerIF* tcStore = nullptr; StorageManagerIF* tcStore = nullptr;
AcceptsTelecommandsIF* tcRecipient = nullptr; AcceptsTelecommandsIF* tcRecipient = nullptr;
@ -104,6 +120,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
TelecommandMap telecommandMap; TelecommandMap telecommandMap;
ReturnValue_t handleResetCommand();
/** /**
* @brief Logic to be performed on an incoming TC[11,4]. * @brief Logic to be performed on an incoming TC[11,4].
* @return RETURN_OK if successful * @return RETURN_OK if successful

View File

@ -38,6 +38,17 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleRequest(
return handleInvalidData("handleRequest"); return handleInvalidData("handleRequest");
} }
switch (subservice) { switch (subservice) {
case Subservice::ENABLE_SCHEDULING: {
schedulingEnabled = true;
break;
}
case Subservice::DISABLE_SCHEDULING: {
schedulingEnabled = false;
break;
}
case Subservice::RESET_SCHEDULING: {
return handleResetCommand();
}
case Subservice::INSERT_ACTIVITY: case Subservice::INSERT_ACTIVITY:
return doInsertActivity(data, size); return doInsertActivity(data, size);
case Subservice::DELETE_ACTIVITY: case Subservice::DELETE_ACTIVITY:
@ -49,25 +60,26 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleRequest(
case Subservice::FILTER_TIMESHIFT_ACTIVITY: case Subservice::FILTER_TIMESHIFT_ACTIVITY:
return doFilterTimeshiftActivity(data, size); return doFilterTimeshiftActivity(data, size);
default: default:
break; return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
} }
return RETURN_OK;
return HasReturnvaluesIF::RETURN_FAILED;
} }
template <size_t MAX_NUM_TCS> template <size_t MAX_NUM_TCS>
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService() { inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService() {
// DEBUG if (not schedulingEnabled) {
// DebugPrintMultimapContent(); return RETURN_OK;
}
// get current time as UNIX timestamp // get current time as UNIX timestamp
timeval tNow = {}; timeval tNow = {};
Clock::getClock_timeval(&tNow); Clock::getClock_timeval(&tNow);
// TODO: Optionally limit the max number of released TCs per cycle?
// NOTE: The iterator is increased in the loop here. Increasing the iterator as for-loop arg // NOTE: The iterator is increased in the loop here. Increasing the iterator as for-loop arg
// does not work in this case as we are deleting the current element here. // does not work in this case as we are deleting the current element here.
for (auto it = telecommandMap.begin(); it != telecommandMap.end();) { for (auto it = telecommandMap.begin(); it != telecommandMap.end();) {
if (it->first <= static_cast<uint32_t>(tNow.tv_sec)) { if (it->first <= static_cast<uint32_t>(tNow.tv_sec)) {
if (schedulingEnabled) {
// release tc // release tc
TmTcMessage releaseMsg(it->second.storeAddr); TmTcMessage releaseMsg(it->second.storeAddr);
auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false); auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false);
@ -75,9 +87,6 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService
if (sendRet != HasReturnvaluesIF::RETURN_OK) { if (sendRet != HasReturnvaluesIF::RETURN_OK) {
return sendRet; return sendRet;
} }
telecommandMap.erase(it++);
if (debugMode) { if (debugMode) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "Released TC & erased it from TC map" << std::endl; sif::info << "Released TC & erased it from TC map" << std::endl;
@ -85,6 +94,10 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService
sif::printInfo("Released TC & erased it from TC map\n"); sif::printInfo("Released TC & erased it from TC map\n");
#endif #endif
} }
telecommandMap.erase(it++);
} else if (deleteExpiredTcWhenDisabled) {
telecommandMap.erase(it++);
}
continue; continue;
} }
it++; it++;
@ -113,6 +126,26 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::initialize() {
return res; return res;
} }
template <size_t MAX_NUM_TCS>
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleResetCommand() {
for (auto it = telecommandMap.begin(); it != telecommandMap.end(); it++) {
ReturnValue_t result = tcStore->deleteData(it->second.storeAddr);
if (result != RETURN_OK) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
// This should not happen
sif::warning << "Service11TelecommandScheduling::handleRequestDeleting: Deletion failed"
<< std::endl;
#else
sif::printWarning("Service11TelecommandScheduling::handleRequestDeleting: Deletion failed\n");
#endif
triggerEvent(TC_DELETION_FAILED, (it->second.requestId >> 32) & 0xffffffff,
it->second.requestId & 0xffffffff);
}
}
telecommandMap.clear();
return RETURN_OK;
}
template <size_t MAX_NUM_TCS> template <size_t MAX_NUM_TCS>
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivity( inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivity(
const uint8_t *data, size_t size) { const uint8_t *data, size_t size) {
@ -582,7 +615,7 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleInvalidD
template <size_t MAX_NUM_TCS> template <size_t MAX_NUM_TCS>
inline void Service11TelecommandScheduling<MAX_NUM_TCS>::debugPrintMultimapContent() const { inline void Service11TelecommandScheduling<MAX_NUM_TCS>::debugPrintMultimapContent() const {
for (const auto &dit : telecommandMap) { for ([[maybe_unused]] const auto &dit : telecommandMap) {
#if FSFW_DISABLE_PRINTOUT == 0 #if FSFW_DISABLE_PRINTOUT == 0
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::debug << "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content" sif::debug << "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content"
@ -600,3 +633,13 @@ inline void Service11TelecommandScheduling<MAX_NUM_TCS>::debugPrintMultimapConte
#endif #endif
} }
} }
template <size_t MAX_NUM_TCS>
inline void Service11TelecommandScheduling<MAX_NUM_TCS>::enableExpiredTcDeletion() {
deleteExpiredTcWhenDisabled = true;
}
template <size_t MAX_NUM_TCS>
inline void Service11TelecommandScheduling<MAX_NUM_TCS>::disableExpiredTcDeletion() {
deleteExpiredTcWhenDisabled = false;
}

View File

@ -9,7 +9,7 @@
CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId) CCSDSDistributor::CCSDSDistributor(uint16_t setDefaultApid, object_id_t setObjectId)
: TcDistributor(setObjectId), defaultApid(setDefaultApid) {} : TcDistributor(setObjectId), defaultApid(setDefaultApid) {}
CCSDSDistributor::~CCSDSDistributor() {} CCSDSDistributor::~CCSDSDistributor() = default;
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() { TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
#if CCSDS_DISTRIBUTOR_DEBUGGING == 1 #if CCSDS_DISTRIBUTOR_DEBUGGING == 1
@ -38,6 +38,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
" store failed!\n"); " store failed!\n");
#endif #endif
#endif #endif
return queueMap.end();
} }
SpacePacketBase currentPacket(packet); SpacePacketBase currentPacket(packet);
@ -45,7 +46,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex
<< currentPacket.getAPID() << std::dec << std::endl; << currentPacket.getAPID() << std::dec << std::endl;
#endif #endif
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID()); auto position = this->queueMap.find(currentPacket.getAPID());
if (position != this->queueMap.end()) { if (position != this->queueMap.end()) {
return position; return position;
} else { } else {

View File

@ -48,8 +48,8 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword sif::warning << "PUSDistributor::handlePacket: Packet format invalid, " << keyword
<< " error" << std::endl; << " error" << std::endl;
#else #else
sif::printWarning( sif::printWarning("PUSDistributor::handlePacket: Packet format invalid, %s error\n",
"PUSDistributor::handlePacket: Packet format invalid, %s error\n", keyword); keyword);
#endif #endif
#endif #endif
} }
@ -131,8 +131,7 @@ ReturnValue_t PUSDistributor::initialize() {
return ObjectManagerIF::CHILD_INIT_FAILED; return ObjectManagerIF::CHILD_INIT_FAILED;
} }
auto* ccsdsDistributor = auto* ccsdsDistributor = ObjectManager::instance()->get<CCSDSDistributorIF>(packetSource);
ObjectManager::instance()->get<CCSDSDistributorIF>(packetSource);
if (ccsdsDistributor == nullptr) { if (ccsdsDistributor == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1 #if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl; sif::error << "PUSDistributor::initialize: Packet source invalid" << std::endl;

View File

@ -9,7 +9,8 @@
class TcPacketStoredIF { class TcPacketStoredIF {
public: public:
virtual ~TcPacketStoredIF()= default;; virtual ~TcPacketStoredIF() = default;
;
/** /**
* With this call, the stored packet can be set to another packet in a store. This is useful * With this call, the stored packet can be set to another packet in a store. This is useful

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ #ifndef FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_
#define FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_ #define FRAMEWORK_TMTCSERVICES_ACCEPTSTELECOMMANDSIF_H_
#include "../ipc/MessageQueueSenderIF.h" #include "fsfw/ipc/MessageQueueSenderIF.h"
/** /**
* @brief This interface is implemented by classes that are sinks for * @brief This interface is implemented by classes that are sinks for
@ -20,7 +20,7 @@ class AcceptsTelecommandsIF {
/** /**
* @brief The virtual destructor as it is mandatory for C++ interfaces. * @brief The virtual destructor as it is mandatory for C++ interfaces.
*/ */
virtual ~AcceptsTelecommandsIF() {} virtual ~AcceptsTelecommandsIF() = default;
/** /**
* @brief Getter for the service id. * @brief Getter for the service id.
* @details Any receiving service (at least any PUS service) shall have a * @details Any receiving service (at least any PUS service) shall have a