Skip to content
Snippets Groups Projects
Commit 7681f03b authored by kpetridis's avatar kpetridis
Browse files

Merged master and resolved conflicts

parents 392951ad 9654faa0
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ add_library(common OBJECT
src/MessageParser.cpp
src/ServicePool.cpp
src/Helpers/CRCHelper.cpp
src/Helpers/PacketStore.cpp
src/Time/UTCTimestamp.cpp
src/Services/EventReportService.cpp
src/Services/MemoryManagementService.cpp
......@@ -39,6 +40,7 @@ add_library(common OBJECT
src/Services/EventActionService.cpp
src/Services/TimeBasedSchedulingService.cpp
src/Services/FunctionManagementService.cpp
src/Services/StorageAndRetrievalService.cpp
src/Services/HousekeepingService.cpp
src/Services/ParameterStatisticsService.cpp
src/Services/OnBoardMonitoringService.cpp
......
#ifndef ECSS_SERVICES_ECSS_DEFINITIONS_H
#define ECSS_SERVICES_ECSS_DEFINITIONS_H
#include <stdint.h>
#include <cstdint>
/**
* @defgroup ECSSDefinitions ECSS Defined Constants
*
......@@ -159,6 +159,25 @@ inline const uint8_t ECSSMaxStatisticParameters = 4;
*/
inline const bool SupportsStandardDeviation = true;
/**
* @brief the max number of bytes allowed for a packet store to handle in ST[15].
*/
inline const uint16_t ECSSMaxPacketStoreSizeInBytes = 1000;
/**
* @brief the max number of TM packets that a packet store in ST[15] can store
*/
inline const uint16_t ECSSMaxPacketStoreSize = 20;
/**
* @brief the max number of packet stores that a packet selection subservice can handle in ST[15]
*/
inline const uint16_t ECSSMaxPacketStores = 4;
/**
* @brief each packet store's id is an etl::string. So this defines the max size of a packet store ID in ST[15]
*/
inline const uint16_t ECSSPacketStoreIdSize = 15;
/**
* @brief Defines the max number of housekeeping structs that the housekeeping service can contain
*/
......@@ -200,12 +219,18 @@ inline const uint8_t ECSSMaxApplicationsServicesCombinations = ECSSMaxControlled
*/
inline const uint8_t ECSSMaxEventDefinitionIDs = 15;
/**
* Limits noting the minimum and maximum valid Virtual Channels used by the Storage and Retrieval subservice
*/
inline struct {
uint8_t min = 1;
uint8_t max = 10;
} VirtualChannelLimits;
/**
* Maximum number of ST[12] Parameter Monitoring Definitions.
*/
inline const uint8_t ECSSMaxMonitoringDefinitions = 4;
/** @} */
#endif // ECSS_SERVICES_ECSS_DEFINITIONS_H
......@@ -77,18 +77,22 @@ public:
* A Message that is included within another message is too large
*/
NestedMessageTooLarge = 11,
/**
* Request to copy packets in a time window, whose type is not recognized (ST(15)).
*/
InvalidTimeWindowType = 12,
/**
* A request to access a non existing housekeeping structure in ST[03]
*/
NonExistentHousekeeping = 12,
NonExistentHousekeeping = 13,
/**
* Attempt to access an invalid parameter in ST[03]
*/
NonExistentParameter = 13,
NonExistentParameter = 14,
/**
* Invalid TimeStamp parameters at creation
*/
InvalidTimeStampInput = 14
InvalidTimeStampInput = 15,
};
/**
......@@ -156,54 +160,125 @@ public:
*/
GetNonExistingParameter = 8,
/**
* Attempt to add definition to the struct map but its already full. (ST[19])
* Attempt to access a packet store that does not exist (ST[15])
*/
NonExistingPacketStore = 9,
/**
* Attempt to change the start time tag of a packet store, whose open retrieval status is in progress (ST[15])
*/
SetPacketStoreWithOpenRetrievalInProgress = 10,
/**
* Attempt to resume open retrieval of a packet store, whose by-time-range retrieval is enabled (ST[15])
*/
EventActionDefinitionsMapIsFull = 9,
SetPacketStoreWithByTimeRangeRetrieval = 11,
/**
* Attempt to access a packet with by-time range retrieval enabled (ST[15])
*/
GetPacketStoreWithByTimeRangeRetrieval = 12,
/**
* Attempt to start the by-time-range retrieval of packet store, whose open retrieval is in progress (ST[15])
*/
GetPacketStoreWithOpenRetrievalInProgress = 13,
/**
* Attempt to start by-time-range retrieval when its already enabled (ST[15])
*/
ByTimeRangeRetrievalAlreadyEnabled = 14,
/**
* Attempt to create packet store, whose ID already exists (ST[15])
*/
AlreadyExistingPacketStore = 15,
/**
* Attempt to create packet store, when the max number of packet stores is already reached (ST[15])
*/
MaxNumberOfPacketStoresReached = 16,
/**
* Attempt to access a packet store with the storage status enabled (ST[15])
*/
GetPacketStoreWithStorageStatusEnabled = 17,
/**
* Attempt to delete a packet whose by time range retrieval status is enabled (ST[15])
*/
DeletionOfPacketWithByTimeRangeRetrieval = 18,
/**
* Attempt to delete a packet whose open retrieval status is in progress (ST[15])
*/
DeletionOfPacketWithOpenRetrievalInProgress = 19,
/**
* Requested a time window where the start time is larger than the end time (ST[15])
*/
InvalidTimeWindow = 20,
/**
* Attempt to copy a packet store to a destination packet store that is not empty (ST[15])
*/
DestinationPacketStoreNotEmtpy = 21,
/**
* Attempt to set a reporting rate which is smaller than the parameter sampling rate.
* ST[04]
*/
InvalidReportingRateError = 22,
/**
* Attempt to add definition to the struct map but its already full.(ST[19])
*/
EventActionDefinitionsMapIsFull = 23,
/**
* Attempt to report/delete non existing housekeeping structure (ST[03])
*/
RequestedNonExistingStructure = 10,
RequestedNonExistingStructure = 24,
/**
* Attempt to create already created structure (ST[03])
*/
RequestedAlreadyExistingStructure = 11,
RequestedAlreadyExistingStructure = 25,
/**
* Attempt to delete structure which has the periodic reporting status enabled (ST[03]) as per 6.3.3.5.2(d-2)
*/
RequestedDeletionOfEnabledHousekeeping = 12,
RequestedDeletionOfEnabledHousekeeping = 26,
/**
* Attempt to append a new parameter ID to a housekeeping structure, but the ID is already in the structure
* (ST[03])
*/
AlreadyExistingParameter = 13,
AlreadyExistingParameter = 27,
/**
* Attempt to append a new parameter id to a housekeeping structure, but the periodic generation status is
* enabled (ST[03])
*/
RequestedAppendToEnabledHousekeeping = 14,
RequestedAppendToEnabledHousekeeping = 28,
/**
* Attempt to create a new housekeeping structure in Housekeeping Service, when the maximum number of
* housekeeping structures is already reached (ST[03])
*/
ExceededMaxNumberOfHousekeepingStructures = 15,
ExceededMaxNumberOfHousekeepingStructures = 29,
/**
* Attempt to add a new simply commutated parameter in a specific housekeeping structure, but the maximum
* number of simply commutated parameters for this structure is already reached (ST[03])
*/
ExceededMaxNumberOfSimplyCommutatedParameters = 16,
/* Attempt to set a reporting rate which is smaller than the parameter sampling rate.
* ST[04]
*/
InvalidReportingRateError = 17,
ExceededMaxNumberOfSimplyCommutatedParameters = 30,
/**
* Attempt to set a sampling rate which is greater than the parameter reporting rate.
* Attempt to set a reporting rate which is smaller than the parameter sampling rate.
* ST[04]
*/
InvalidSamplingRateError = 18,
InvalidSamplingRateError = 31,
/**
* Attempt to add new statistic definition but the maximum number is already reached (ST[04])
*/
MaxStatisticDefinitionsReached = 19,
MaxStatisticDefinitionsReached = 32,
/**
* Attempt to set the virtual channel of a packet store to a invalid value (ST[15])
*/
InvalidVirtualChannel = 33,
/**
* Attempt to delete a packet store, whose storage status is enabled (ST[15])
*/
DeletionOfPacketStoreWithStorageStatusEnabled = 34,
/**
* Attempt to copy packets from a packet store to another, but either no packet timestamp falls inside the
* specified timestamp, or more than one boolean argument were given as true in the 'copyPacketsTo' function
* (ST[15])
*/
CopyOfPacketsFailed = 35,
/**
* Attempt to set a packet store size to a value that the available memory cannot handle (ST[15]).
*/
UnableToHandlePacketStoreSize = 36,
/**
* Attempt to add a new report type, when the addition of all report types is already enabled in the
* Application Process configuration (ST[14])
......@@ -233,47 +308,47 @@ public:
* Attempt to delete all parameter monitoring definitions but the Parameter Monitoring Function Status is
* enabled.
*/
InvalidRequestToDeleteAllParameterMonitoringDefinitions = 25,
InvalidRequestToDeleteAllParameterMonitoringDefinitions = 37,
/**
* Attempt to delete one parameter monitoring definition but its Parameter Monitoring Status is
* enabled.
*/
InvalidRequestToDeleteParameterMonitoringDefinition = 26,
InvalidRequestToDeleteParameterMonitoringDefinition = 38,
/**
* Attempt to add a parameter that already exists to the Parameter Monitoring List.
*/
AddAlreadyExistingParameter = 27,
AddAlreadyExistingParameter = 39,
/**
* Attempt to add a parameter in the Parameter Monitoring List but it's full
*/
ParameterMonitoringListIsFull = 28,
ParameterMonitoringListIsFull = 40,
/**
* Attempt to add or modify a limit check parameter monitoring definition, but the high limit is lower than
* the low limit.
*/
HighLimitIsLowerThanLowLimit = 29,
HighLimitIsLowerThanLowLimit = 41,
/**
* Attempt to add or modify a delta check parameter monitoring definition, but the high threshold is lower than
* the low threshold.
*/
HighThresholdIsLowerThanLowThreshold = 30,
HighThresholdIsLowerThanLowThreshold = 42,
/**
* Attempt to modify a non existent Parameter Monitoring definition.
*/
ModifyParameterNotInTheParameterMonitoringList = 31,
ModifyParameterNotInTheParameterMonitoringList = 43,
/**
* Attempt to modify a parameter monitoring definition, but the instruction refers to a monitored parameter
* that is not the one used in that parameter monitoring definition.
*/
DifferentParameterMonitoringDefinitionAndMonitoredParameter = 32,
DifferentParameterMonitoringDefinitionAndMonitoredParameter = 44,
/**
* Attempt to get a parameter monitoring definition that does not exist.
*/
GetNonExistingParameterMonitoringDefinition = 33,
GetNonExistingParameterMonitoringDefinition = 45,
/**
* Request to report a non existent parameter monitoring definition.
*/
ReportParameterNotInTheParameterMonitoringList = 34
ReportParameterNotInTheParameterMonitoringList = 46
};
/**
......
#ifndef ECSS_SERVICES_PACKETSTORE_HPP
#define ECSS_SERVICES_PACKETSTORE_HPP
#include "ECSS_Definitions.hpp"
#include "ErrorHandler.hpp"
#include "etl/deque.h"
#include "Message.hpp"
/**
* This is the Packet Store class, needed for the Storage-Retrieval Service. The purpose of the packet-store is to
* store all the TM packets transmitted by the other Services.
*/
class PacketStore {
public:
/**
* The virtual channel used to transmit the packet store to the ground station. There is an upper and a lower
* bound for the virtual channels, defined in 'ECSSDefinitions' file.
*/
uint8_t virtualChannel;
/**
* The time-tag that defines the starting point of the open retrieval process, meaning that we retrieve packets,
* starting from the open-retrieval-start-time-tag until the latest packet.
*/
uint32_t openRetrievalStartTimeTag = 0;
/**
* The start time of a by-time-range retrieval process, i.e. retrieval of packets between two specified time-tags.
*/
uint32_t retrievalStartTime = 0;
/**
* The end time of a by-time-range retrieval process, i.e. retrieval of packets between two specified time-tags.
*/
uint32_t retrievalEndTime = 0;
/**
* The maximum size of the packet store, in bytes.
*
* @todo: add a way of defining each packets store's size in bytes
*/
uint64_t sizeInBytes;
/**
* Whether the insertion of packets stores in the packet-store should cyclically overwrite older packets, or be
* suspended when the packet-store is full.
*/
enum PacketStoreType : uint8_t { Circular = 0, Bounded = 1 };
/**
* Whether the open retrieval status of the packet-store is in progress or not.
*/
enum PacketStoreOpenRetrievalStatus : bool { Suspended = false, InProgress = true };
/**
+ * Whether the storage of TM packets is enabled for this packet store
*/
bool storageStatus = false;
/**
* Whether the by-time-range retrieval of packet stores is enabled for this packet-store.
*/
bool byTimeRangeRetrievalStatus = false;
PacketStoreType packetStoreType;
PacketStoreOpenRetrievalStatus openRetrievalStatus;
PacketStore() = default;
/**
* A queue containing the TM messages stored by the packet store. Every TM is accompanied by its timestamp.
*
* @note A convention is made that this should be filled out using `push_back` and NOT `push_front`, dictating that
* earlier packets are placed in the front position. So removing the earlier packets is done with `pop_front`.
*
* old packets <----------> new packets
* [][][][][][][][][][][][][][][][][][][] <--- deque
*/
etl::deque<std::pair<uint32_t, Message>, ECSSMaxPacketStoreSize> storedTelemetryPackets;
/**
* Returns the sum of the sizes of the packets stored in this PacketStore, in bytes.
*/
uint16_t calculateSizeInBytes();
};
#endif
......@@ -18,25 +18,22 @@
* @{
*/
#define SERVICE_ALL ///< Enables compilation of all the ECSS services
#ifdef SERVICE_ALL
#define SERVICE_EVENTACTION ///< Compile ST[19] event-action
#define SERVICE_EVENTREPORT ///< Compile ST[05] event reporting
#define SERVICE_FUNCTION ///< Compile ST[08] function management
#define SERVICE_HOUSEKEEPING ///< Compile ST[03] housekeeping
#define SERVICE_LARGEPACKET ///< Compile ST[13] large packet transfer
#define SERVICE_MEMORY ///< Compile ST[06] memory management
#define SERVICE_ONBOARDMONITORING ///< Compile ST[12] on-board monitoring
#define SERVICE_PARAMETER ///< Compile ST[20] parameter management
#define SERVICE_PARAMETERSTATISTICS ///< Compile ST[04] parameter statistics
#define SERVICE_REALTIMEFORWARDINGCONTROL ///< Compile ST[14] real time forwarding control
#define SERVICE_REQUESTVERIFICATION ///< Compile ST[01] request verification
#define SERVICE_TEST ///< Compile ST[17] test
#define SERVICE_TIME ///< Compile ST[09] time management
#define SERVICE_TIMESCHEDULING ///< Compile ST[11] time-based scheduling
#endif
#define SERVICE_ALL ///< Enables compilation of all the ECSS services
#define SERVICE_EVENTACTION ///< Compile ST[19] event-action
#define SERVICE_EVENTREPORT ///< Compile ST[05] event reporting
#define SERVICE_FUNCTION ///< Compile ST[08] function management
#define SERVICE_HOUSEKEEPING ///< Compile ST[03] housekeeping
#define SERVICE_LARGEPACKET ///< Compile ST[13] large packet transfer
#define SERVICE_MEMORY ///< Compile ST[06] memory management
#define SERVICE_ONBOARDMONITORING ///< Compile ST[12] on-board monitoring
#define SERVICE_PARAMETER ///< Compile ST[20] parameter management
#define SERVICE_PARAMETERSTATISTICS ///< Compile ST[04] parameter statistics
#define SERVICE_REALTIMEFORWARDINGCONTROL ///< Compile ST[14] real time forwarding control
#define SERVICE_REQUESTVERIFICATION ///< Compile ST[01] request verification
#define SERVICE_STORAGEANDRETRIEVAL ///< Compile ST[15] storage-and-retrieval of tm packets
#define SERVICE_TEST ///< Compile ST[17] test
#define SERVICE_TIME ///< Compile ST[09] time management
#define SERVICE_TIMESCHEDULING ///< Compile ST[11] time-based scheduling
/** @} */
#endif // ECSS_SERVICES_ECSS_CONFIGURATION_HPP
......@@ -11,6 +11,7 @@
#include "Services/TestService.hpp"
#include "Services/MemoryManagementService.hpp"
#include "Services/FunctionManagementService.hpp"
#include "Services/StorageAndRetrievalService.hpp"
#include "Services/HousekeepingService.hpp"
#include "Services/ParameterStatisticsService.hpp"
#include "Services/RealTimeForwardingControlService.hpp"
......@@ -82,6 +83,10 @@ public:
RequestVerificationService requestVerification;
#endif
#ifdef SERVICE_STORAGEANDRETRIEVAL
StorageAndRetrievalService storageAndRetrieval;
#endif
#ifdef SERVICE_TEST
TestService testService;
#endif
......
#ifndef ECSS_SERVICES_STORAGEANDRETRIEVALSERVICE_HPP
#define ECSS_SERVICES_STORAGEANDRETRIEVALSERVICE_HPP
#include "ECSS_Definitions.hpp"
#include "Service.hpp"
#include "ErrorHandler.hpp"
#include "Helpers/PacketStore.hpp"
#include "etl/map.h"
/**
* Implementation of ST[15] Storage and Retrieval Service, as defined in ECSS-E-ST-70-41C.
*
* This Service:
* - provides the capability to select reports generated by other services and store them into packet stores.
* - allows the ground system to manage the reports in the packet stores and request their downlink.
*
* @author Konstantinos Petridis <petridkon@gmail.com>
*/
class StorageAndRetrievalService : public Service {
public:
/**
* The type of timestamps that the Storage and Retrieval Subservice assigns to each incoming packet.
*/
enum TimeStampType : uint8_t { StorageBased = 0, PacketBased = 1 };
/**
* Different types of packet retrieval from a packet store, relative to a specified time-tag.
*/
enum TimeWindowType : uint8_t { FromTagToTag = 0, AfterTimeTag = 1, BeforeTimeTag = 2 };
/**
* The type of timestamps that the subservice sets to each incoming telemetry packet.
*/
const TimeStampType timeStamping = PacketBased;
private:
typedef String<ECSSPacketStoreIdSize> packetStoreId;
/**
* All packet stores, held by the Storage and Retrieval Service. Each packet store has its ID as key.
*/
etl::map<packetStoreId, PacketStore, ECSSMaxPacketStores> packetStores;
/**
* Helper function that reads the packet store ID string from a TM[15] message
*/
static inline String<ECSSPacketStoreIdSize> readPacketStoreId(Message& message);
/**
* Helper function that, given a time-limit, deletes every packet stored in the specified packet-store, up to the
* requested time.
*
* @param packetStoreId required to access the correct packet store.
* @param timeLimit the limit until which, packets are deleted.
*/
void deleteContentUntil(const String<ECSSPacketStoreIdSize>& packetStoreId, uint32_t timeLimit);
/**
* Copies all TM packets from source packet store to the target packet-store, that fall between the two specified
* time-tags as per 6.15.3.8.4.d(1) of the standard.
*
* @param request used to read the time-tags, the packet store IDs and to raise errors.
*/
void copyFromTagToTag(Message& request);
/**
* Copies all TM packets from source packet store to the target packet-store, whose time-stamp is after the
* specified time-tag as per 6.15.3.8.4.d(2) of the standard.
*
* @param request used to read the time-tag, the packet store IDs and to raise errors.
*/
void copyAfterTimeTag(Message& request);
/**
* Copies all TM packets from source packet store to the target packet-store, whose time-stamp is before the
* specified time-tag as per 6.15.3.8.4.d(3) of the standard.
*
* @param request used to raise errors.
*/
void copyBeforeTimeTag(Message& request);
/**
* Checks if the two requested packet stores exist.
*
* @param fromPacketStoreId the source packet store, whose content is to be copied.
* @param toPacketStoreId the target packet store, which is going to receive the new content.
* @param request used to raise errors.
* @return true if an error has occurred.
*/
bool checkPacketStores(const String<ECSSPacketStoreIdSize>& fromPacketStoreId,
const String<ECSSPacketStoreIdSize>& toPacketStoreId, Message& request);
/**
* Checks whether the time window makes logical sense (end time should be after the start time)
*
* @param request used to raise errors.
*/
static bool checkTimeWindow(uint32_t startTime, uint32_t endTime, Message& request);
/**
* Checks if the destination packet store is empty, in order to proceed with the copying of packets.
*
* @param toPacketStoreId the target packet store, which is going to receive the new content. Needed for error
* checking.
* @param request used to raise errors.
*/
bool checkDestinationPacketStore(const String<ECSSPacketStoreIdSize>& toPacketStoreId, Message& request);
/**
* Checks if there are no stored timestamps that fall between the two specified time-tags.
*
* @param fromPacketStoreId the source packet store, whose content is to be copied. Needed for error checking.
* @param request used to raise errors.
*
* @note
* This function assumes that `startTime` and `endTime` are valid at this point, so any necessary error checking
* regarding these variables, should have already occurred.
*/
bool noTimestampInTimeWindow(const String<ECSSPacketStoreIdSize>& fromPacketStoreId, uint32_t startTime,
uint32_t endTime, Message& request);
/**
* Checks if there are no stored timestamps that fall between the two specified time-tags.
*
* @param isAfterTimeTag true indicates that we are examining the case of AfterTimeTag. Otherwise, we are referring
* to the case of BeforeTimeTag.
* @param request used to raise errors.
* @param fromPacketStoreId the source packet store, whose content is to be copied.
*/
bool noTimestampInTimeWindow(const String<ECSSPacketStoreIdSize>& fromPacketStoreId, uint32_t timeTag,
Message& request, bool isAfterTimeTag);
/**
* Performs all the necessary error checking for the case of FromTagToTag copying of packets.
*
* @param fromPacketStoreId the source packet store, whose content is to be copied.
* @param toPacketStoreId the target packet store, which is going to receive the new content.
* @param request used to raise errors.
* @return true if an error has occurred.
*/
bool failedFromTagToTag(const String<ECSSPacketStoreIdSize>& fromPacketStoreId,
const String<ECSSPacketStoreIdSize>& toPacketStoreId, uint32_t startTime,
uint32_t endTime, Message& request);
/**
* Performs all the necessary error checking for the case of AfterTimeTag copying of packets.
*
* @param fromPacketStoreId the source packet store, whose content is to be copied.
* @param toPacketStoreId the target packet store, which is going to receive the new content.
* @param request used to raise errors.
* @return true if an error has occurred.
*/
bool failedAfterTimeTag(const String<ECSSPacketStoreIdSize>& fromPacketStoreId,
const String<ECSSPacketStoreIdSize>& toPacketStoreId, uint32_t startTime,
Message& request);
/**
* Performs all the necessary error checking for the case of BeforeTimeTag copying of packets.
*
* @param fromPacketStoreId the source packet store, whose content is to be copied.
* @param toPacketStoreId the target packet store, which is going to receive the new content.
* @param request used to raise errors.
* @return true if an error has occurred.
*/
bool failedBeforeTimeTag(const String<ECSSPacketStoreIdSize>& fromPacketStoreId,
const String<ECSSPacketStoreIdSize>& toPacketStoreId, uint32_t endTime,
Message& request);
/**
* Performs the necessary error checking for a request to start the by-time-range retrieval process.
*
* @param request used to raise errors.
* @return true if an error has occurred.
*/
bool failedStartOfByTimeRangeRetrieval(const String<ECSSPacketStoreIdSize>& packetStoreId, Message& request);
/**
* Forms the content summary of the specified packet-store and appends it to a report message.
*/
void createContentSummary(Message& report, const String<ECSSPacketStoreIdSize>& packetStoreId);
public:
inline static const uint8_t ServiceType = 15;
enum MessageType : uint8_t {
EnableStorageInPacketStores = 1,
DisableStorageInPacketStores = 2,
StartByTimeRangeRetrieval = 9,
DeletePacketStoreContent = 11,
ReportContentSummaryOfPacketStores = 12,
PacketStoreContentSummaryReport = 13,
ChangeOpenRetrievalStartingTime = 14,
ResumeOpenRetrievalOfPacketStores = 15,
SuspendOpenRetrievalOfPacketStores = 16,
AbortByTimeRangeRetrieval = 17,
ReportStatusOfPacketStores = 18,
PacketStoresStatusReport = 19,
CreatePacketStores = 20,
DeletePacketStores = 21,
ReportConfigurationOfPacketStores = 22,
PacketStoreConfigurationReport = 23,
CopyPacketsInTimeWindow = 24,
ResizePacketStores = 25,
ChangeTypeToCircular = 26,
ChangeTypeToBounded = 27,
ChangeVirtualChannel = 28
};
StorageAndRetrievalService() = default;
/**
* Adds new packet store into packet stores.
*/
void addPacketStore(const String<ECSSPacketStoreIdSize>& packetStoreId, const PacketStore& packetStore);
/**
* Adds telemetry to the specified packet store and timestamps it.
*/
void addTelemetryToPacketStore(const String<ECSSPacketStoreIdSize>& packetStoreId, uint32_t timestamp);
/**
* Deletes the content from all the packet stores.
*/
void resetPacketStores();
/**
* Returns the number of existing packet stores.
*/
uint16_t currentNumberOfPacketStores();
/**
* Returns the packet store with the specified packet store ID.
*/
PacketStore& getPacketStore(const String<ECSSPacketStoreIdSize>& packetStoreId);
/**
* Returns true if the specified packet store is present in packet stores.
*/
bool packetStoreExists(const String<ECSSPacketStoreIdSize>& packetStoreId);
/**
* Given a request that contains a number N, followed by N packet store IDs, this method calls function on every
* packet store. Implemented to reduce duplication. If N = 0, then function is applied to all packet stores.
* Incorrect packet store IDs are ignored and generate an error.
* @param function the job to be done after the error checking.
*/
void executeOnPacketStores(Message& request, const std::function<void(PacketStore&)>& function);
/**
* TC[15,1] request to enable the packet stores' storage function
*/
void enableStorageFunction(Message& request);
/**
* TC[15,2] request to disable the packet stores' storage function
*/
void disableStorageFunction(Message& request);
/**
* TC[15,9] start the by-time-range retrieval of packet stores
*/
void startByTimeRangeRetrieval(Message& request);
/**
* TC[15,11] delete the packet store content up to the specified time
*/
void deletePacketStoreContent(Message& request);
/**
* This function takes a TC[15,12] 'report the packet store content summary' as argument and responds with a TM[15,
* 13] 'packet store content summary report' report message.
*/
void packetStoreContentSummaryReport(Message& request);
/**
* TC[15,14] change the open retrieval start time tag
*/
void changeOpenRetrievalStartTimeTag(Message& request);
/**
* TC[15,15] resume the open retrieval of packet stores
*/
void resumeOpenRetrievalOfPacketStores(Message& request);
/**
* TC[15,16] suspend the open retrieval of packet stores
*/
void suspendOpenRetrievalOfPacketStores(Message& request);
/**
* TC[15,17] abort the by-time-range retrieval of packet stores
*/
void abortByTimeRangeRetrieval(Message& request);
/**
* This function takes a TC[15,18] 'report the status of packet stores' request as argument and responds with a
* TM[15,19] 'packet stores status' report message.
*/
void packetStoresStatusReport(Message& request);
/**
* TC[15,20] create packet stores
*/
void createPacketStores(Message& request);
/**
* TC[15,21] delete packet stores
*/
void deletePacketStores(Message& request);
/**
* This function takes a TC[15,22] 'report the packet store configuration' as argument and responds with a TM[15,
* 23] 'packet store configuration report' report message.
*/
void packetStoreConfigurationReport(Message& request);
/**
* TC[15,24] copy the packets contained into a packet store, selected by the time window
*/
void copyPacketsInTimeWindow(Message& request);
/**
* TC[15,25] resize packet stores
*/
void resizePacketStores(Message& request);
/**
* TC[15,26] change the packet store type to circular
*/
void changeTypeToCircular(Message& request);
/**
* TC[15,27] change the packet store type to bounded
*/
void changeTypeToBounded(Message& request);
/**
* TC[15,28] change the virtual channel used by a packet store
*/
void changeVirtualChannel(Message& request);
/**
* It is responsible to call the suitable function that executes a telecommand packet. The source of that packet
* is the ground station.
*
* @note This function is called from the main execute() that is defined in the file MessageParser.hpp
* @param request Contains the necessary parameters to call the suitable subservice
*/
void execute(Message& request);
};
#endif
#include "Helpers/PacketStore.hpp"
uint16_t PacketStore::calculateSizeInBytes() {
uint16_t size = 0;
for (auto& tmPacket : storedTelemetryPackets) {
size += tmPacket.second.dataSize;
}
return size;
}
#include "MessageParser.hpp"
#include <ServicePool.hpp>
#include <iostream>
#include "ErrorHandler.hpp"
#include "MessageParser.hpp"
#include "macros.hpp"
#include "Services/RequestVerificationService.hpp"
#include "Helpers/CRCHelper.hpp"
#include "Services/RequestVerificationService.hpp"
#include "macros.hpp"
void MessageParser::execute(Message& message) {
switch (message.serviceType) {
......@@ -44,6 +45,11 @@ void MessageParser::execute(Message& message) {
break;
#endif
#ifdef SERVICE_STORAGEANDRETRIEVAL
case StorageAndRetrievalService::ServiceType:
Services.storageAndRetrieval.execute(message);
#endif
#ifdef SERVICE_ONBOARDMONITORING
case OnBoardMonitoringService::ServiceType:
Services.onBoardMonitoringService.execute(message);
......@@ -194,7 +200,7 @@ String<CCSDSMaxMessageSize> MessageParser::compose(const Message& message) {
// Parts of the header
uint16_t packetId = message.applicationId;
packetId |= (1U << 11U); // Secondary header flag
packetId |= (1U << 11U); // Secondary header flag
packetId |= (message.packetType == Message::TC) ? (1U << 12U) : (0U); // Ignore-MISRA
uint16_t packetSequenceControl = message.packetSequenceCount | (3U << 14U);
uint16_t packetDataLength = ecssMessage.size();
......
This diff is collapsed.
#include "Helpers/PacketStore.hpp"
#include "catch2/catch.hpp"
TEST_CASE("Counting a packet store's size in bytes") {
SECTION("Correct counting of size in bytes") {
Message tm1;
tm1.appendUint8(4);
tm1.appendFloat(5.6);
PacketStore packetStore;
packetStore.storedTelemetryPackets.push_back({2, tm1});
REQUIRE(packetStore.storedTelemetryPackets.size() == 1);
REQUIRE(packetStore.calculateSizeInBytes() == 5);
Message tm2;
tm2.appendBoolean(true);
tm2.appendUint16(45);
tm2.appendUint8(3);
tm2.appendUint32(55);
packetStore.storedTelemetryPackets.push_back({2, tm2});
REQUIRE(packetStore.storedTelemetryPackets.size() == 2);
REQUIRE(packetStore.calculateSizeInBytes() == 13);
Message tm3;
tm3.appendUint64(743);
tm3.appendUint8(3);
tm3.appendUint32(55);
packetStore.storedTelemetryPackets.push_back({3, tm3});
REQUIRE(packetStore.storedTelemetryPackets.size() == 3);
REQUIRE(packetStore.calculateSizeInBytes() == 26);
}
}
\ No newline at end of file
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment