EIVE upstream #29

Merged
muellerr merged 693 commits from use-eive-upstream into develop 2023-06-30 15:44:39 +02:00
8 changed files with 101 additions and 40 deletions
Showing only changes of commit fbec1b3dc9 - Show all commits

View File

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

View File

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

View File

@ -44,18 +44,26 @@ class Service11TelecommandScheduling final : public PusServiceBase {
static constexpr ReturnValue_t INVALID_RELATIVE_TIME =
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
enum [[maybe_unused]] Subservice : uint8_t{ENABLE_SCHEDULING = 1,
DISABLE_SCHEDULING = 2,
RESET_SCHEDULING = 3,
INSERT_ACTIVITY = 4,
DELETE_ACTIVITY = 5,
FILTER_DELETE_ACTIVITY = 6,
TIMESHIFT_ACTIVITY = 7,
FILTER_TIMESHIFT_ACTIVITY = 8,
DETAIL_REPORT = 9,
TIMEBASE_SCHEDULE_DETAIL_REPORT = 10,
TIMESHIFT_ALL_SCHEDULE_ACTIVITIES = 15};
enum Subservice : uint8_t {
ENABLE_SCHEDULING = 1,
DISABLE_SCHEDULING = 2,
RESET_SCHEDULING = 3,
INSERT_ACTIVITY = 4,
DELETE_ACTIVITY = 5,
FILTER_DELETE_ACTIVITY = 6,
TIMESHIFT_ACTIVITY = 7,
FILTER_TIMESHIFT_ACTIVITY = 8,
DETAIL_REPORT = 9,
TIMEBASE_SCHEDULE_DETAIL_REPORT = 10,
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,
// requirement 8.11.3c (p. 507)
@ -73,6 +81,9 @@ class Service11TelecommandScheduling final : public PusServiceBase {
~Service11TelecommandScheduling() override;
void enableExpiredTcDeletion();
void disableExpiredTcDeletion();
/** PusServiceBase overrides */
ReturnValue_t handleRequest(uint8_t subservice) override;
ReturnValue_t performService() override;
@ -90,6 +101,11 @@ class Service11TelecommandScheduling final : public PusServiceBase {
// minimum release time offset to insert into schedule
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;
StorageManagerIF* tcStore = nullptr;
AcceptsTelecommandsIF* tcRecipient = nullptr;
@ -104,6 +120,7 @@ class Service11TelecommandScheduling final : public PusServiceBase {
TelecommandMap telecommandMap;
ReturnValue_t handleResetCommand();
/**
* @brief Logic to be performed on an incoming TC[11,4].
* @return RETURN_OK if successful

View File

@ -38,6 +38,17 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleRequest(
return handleInvalidData("handleRequest");
}
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:
return doInsertActivity(data, size);
case Subservice::DELETE_ACTIVITY:
@ -49,41 +60,43 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::handleRequest(
case Subservice::FILTER_TIMESHIFT_ACTIVITY:
return doFilterTimeshiftActivity(data, size);
default:
break;
return AcceptsTelecommandsIF::INVALID_SUBSERVICE;
}
return HasReturnvaluesIF::RETURN_FAILED;
return RETURN_OK;
}
template <size_t MAX_NUM_TCS>
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::performService() {
// DEBUG
// DebugPrintMultimapContent();
if (not schedulingEnabled) {
return RETURN_OK;
}
// get current time as UNIX timestamp
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
// does not work in this case as we are deleting the current element here.
for (auto it = telecommandMap.begin(); it != telecommandMap.end();) {
if (it->first <= static_cast<uint32_t>(tNow.tv_sec)) {
// release tc
TmTcMessage releaseMsg(it->second.storeAddr);
auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false);
if (schedulingEnabled) {
// release tc
TmTcMessage releaseMsg(it->second.storeAddr);
auto sendRet = this->requestQueue->sendMessage(recipientMsgQueueId, &releaseMsg, false);
if (sendRet != HasReturnvaluesIF::RETURN_OK) {
return sendRet;
}
telecommandMap.erase(it++);
if (debugMode) {
if (sendRet != HasReturnvaluesIF::RETURN_OK) {
return sendRet;
}
if (debugMode) {
#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;
#else
sif::printInfo("Released TC & erased it from TC map\n");
sif::printInfo("Released TC & erased it from TC map\n");
#endif
}
telecommandMap.erase(it++);
} else if (deleteExpiredTcWhenDisabled) {
telecommandMap.erase(it++);
}
continue;
}
@ -113,6 +126,26 @@ inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::initialize() {
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>
inline ReturnValue_t Service11TelecommandScheduling<MAX_NUM_TCS>::doInsertActivity(
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>
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_CPP_OSTREAM_ENABLED == 1
sif::debug << "Service11TelecommandScheduling::debugPrintMultimapContent: Multimap Content"
@ -600,3 +633,13 @@ inline void Service11TelecommandScheduling<MAX_NUM_TCS>::debugPrintMultimapConte
#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)
: TcDistributor(setObjectId), defaultApid(setDefaultApid) {}
CCSDSDistributor::~CCSDSDistributor() {}
CCSDSDistributor::~CCSDSDistributor() = default;
TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
#if CCSDS_DISTRIBUTOR_DEBUGGING == 1
@ -38,6 +38,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
" store failed!\n");
#endif
#endif
return queueMap.end();
}
SpacePacketBase currentPacket(packet);
@ -45,7 +46,7 @@ TcDistributor::TcMqMapIter CCSDSDistributor::selectDestination() {
sif::info << "CCSDSDistributor::selectDestination has packet with APID " << std::hex
<< currentPacket.getAPID() << std::dec << std::endl;
#endif
TcMqMapIter position = this->queueMap.find(currentPacket.getAPID());
auto position = this->queueMap.find(currentPacket.getAPID());
if (position != this->queueMap.end()) {
return position;
} else {

View File

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

View File

@ -9,7 +9,8 @@
class TcPacketStoredIF {
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

View File

@ -1,7 +1,7 @@
#ifndef 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
@ -20,7 +20,7 @@ class AcceptsTelecommandsIF {
/**
* @brief The virtual destructor as it is mandatory for C++ interfaces.
*/
virtual ~AcceptsTelecommandsIF() {}
virtual ~AcceptsTelecommandsIF() = default;
/**
* @brief Getter for the service id.
* @details Any receiving service (at least any PUS service) shall have a