delete code which is not used anymore
Some checks failed
fsfw/fsfw/pipeline/pr-development There was a failure building this commit

This commit is contained in:
Robin Müller 2022-07-21 17:57:31 +02:00
parent 5af3138e81
commit 61bc867bed
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
19 changed files with 3 additions and 1104 deletions

View File

@ -3,7 +3,6 @@
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/pus/servicepackets/Service1Packets.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
#include "fsfw/tmtcservices/AcceptsTelemetryIF.h"
#include "fsfw/tmtcservices/PusVerificationReport.h"
#include "fsfw/tmtcservices/tmHelpers.h"

View File

@ -5,7 +5,6 @@
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/pus/servicepackets/Service5Packets.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcpacket/pus/tm/TmPacketStored.h"
#include "fsfw/tmtcservices/tmHelpers.h"
Service5EventReporting::Service5EventReporting(object_id_t objectId, uint16_t apid,

View File

@ -1,8 +1,8 @@
#ifndef FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
#define FSFW_TMTCPACKET_CFDP_CFDPPACKETSTORED_H_
#include "../pus/tc/TcPacketStoredBase.h"
#include "CfdpPacket.h"
#include "fsfw/storagemanager/storeAddress.h"
class CfdpPacketStored : public CfdpReader {
public:

View File

@ -1,4 +1,2 @@
target_sources(${LIB_FSFW_NAME} PRIVATE PusTcReader.cpp PusTcReader.cpp
PusTcCreator.cpp)
# TcPacketPus.cpp

View File

@ -1,99 +0,0 @@
#include "TcPacketPus.h"
#include <cstring>
#include "fsfw/globalfunctions/CRC.h"
TcPacketPus::TcPacketPus(const uint8_t *setData) : TcPacketPusBase(setData) {
tcData = reinterpret_cast<TcPacketPointer *>(const_cast<uint8_t *>(setData));
}
void TcPacketPus::initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack,
uint8_t service, uint8_t subservice,
ecss::PusVersion pusVersion, uint16_t sourceId) {
initSpacePacketHeader(true, true, apid, sequenceCount);
std::memset(&tcData->dataField, 0, sizeof(tcData->dataField));
setPacketDataLength(sizeof(PUSTcDataFieldHeader) + CRC_SIZE - 1);
// Data Field Header. For PUS A, the first bit (CCSDS Secondary Header Flag) is zero
tcData->dataField.versionTypeAck = pusVersion << 4 | (ack & 0x0F);
tcData->dataField.serviceType = service;
tcData->dataField.serviceSubtype = subservice;
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
tcData->dataField.sourceIdH = (sourceId >> 8) | 0xff;
tcData->dataField.sourceIdL = sourceId & 0xff;
#else
tcData->dataField.sourceId = sourceId;
#endif
}
uint8_t TcPacketPus::getService() const { return tcData->dataField.serviceType; }
uint8_t TcPacketPus::getSubService() const { return tcData->dataField.serviceSubtype; }
uint8_t TcPacketPus::getAcknowledgeFlags() const {
return tcData->dataField.versionTypeAck & 0b00001111;
}
const uint8_t *TcPacketPus::getApplicationData() const { return &tcData->appData; }
uint16_t TcPacketPus::getApplicationDataSize() const {
return SpacePacketReader::getPacketDataLen() - sizeof(tcData->dataField) - CRC_SIZE + 1;
}
uint16_t TcPacketPus::getErrorControl() const {
uint16_t size = getApplicationDataSize() + CRC_SIZE;
uint8_t *p_to_buffer = &tcData->appData;
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
}
void TcPacketPus::setErrorControl() {
uint32_t full_size = getFullSize();
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
uint32_t size = getApplicationDataSize();
(&tcData->appData)[size] = (crc & 0XFF00) >> 8; // CRCH
(&tcData->appData)[size + 1] = (crc)&0X00FF; // CRCL
}
uint8_t TcPacketPus::getSecondaryHeaderFlag() const {
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
// Does not exist for PUS C
return 0;
#else
return (tcData->dataField.versionTypeAck & 0b10000000) >> 7;
#endif
}
uint8_t TcPacketPus::getPusVersionNumber() const {
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
return (tcData->dataField.versionTypeAck & 0b11110000) >> 4;
#else
return (tcData->dataField.versionTypeAck & 0b01110000) >> 4;
#endif
}
uint16_t TcPacketPus::getSourceId() const {
#if FSFW_USE_PUS_C_TELECOMMANDS == 1
return (tcData->dataField.sourceIdH << 8) | tcData->dataField.sourceIdL;
#else
return tcData->dataField.sourceId;
#endif
}
size_t TcPacketPus::calculateFullPacketLength(size_t appDataLen) const {
return sizeof(CCSDSPrimaryHeader) + sizeof(PUSTcDataFieldHeader) + appDataLen +
TcPacketPusBase::CRC_SIZE;
}
ReturnValue_t TcPacketPus::setData(uint8_t *dataPtr, size_t maxSize, void *args) {
ReturnValue_t result = SpacePacketReader::setData(dataPtr, maxSize, args);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (maxSize < sizeof(TcPacketPointer)) {
return HasReturnvaluesIF::RETURN_FAILED;
}
// This function is const-correct, but it was decided to keep the pointer non-const
// for convenience. Therefore, cast away constness here and then cast to packet type.
tcData = reinterpret_cast<TcPacketPointer *>(const_cast<uint8_t *>(dataPtr));
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -1,69 +0,0 @@
#ifndef FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
#define FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_
#include <cstdint>
#include "../defs.h"
#include "PusTcReader.h"
#include "fsfw/FSFW.h"
#include "fsfw/tmtcpacket/ccsds/defs.h"
/**
* This struct defines the data structure of a PUS Telecommand A packet when
* accessed via a pointer.
* @ingroup tmtcpackets
*/
/*
struct TcPacketPointer {
CCSDSPrimaryHeader primary;
PusTcDataFieldHeader dataField;
uint8_t appData;
};
*/
// class TcPacketPus : public TcPacketPusBase {
// public:
// /**
// * Initialize a PUS A telecommand packet which already exists. You can also
// * create an empty (invalid) object by passing nullptr as the data pointer
// * @param setData
// */
// TcPacketPus(const uint8_t* setData);
//
// // Base class overrides
// uint8_t getSecondaryHeaderFlag() const override;
// uint8_t getPusVersionNumber() const override;
// uint8_t getAcknowledgeFlags() const override;
// uint8_t getService() const override;
// uint8_t getSubService() const override;
// uint16_t getSourceId() const override;
// const uint8_t* getApplicationData() const override;
// uint16_t getApplicationDataSize() const override;
// uint16_t getErrorControl() const override;
// void setErrorControl() override;
// size_t calculateFullPacketLength(size_t appDataLen) const override;
//
// protected:
// ReturnValue_t setData(uint8_t* dataPtr, size_t maxSize, void* args) override;
//
// /**
// * Initializes the Tc Packet header.
// * @param apid APID used.
// * @param sequenceCount Sequence Count in the primary header.
// * @param ack Which acknowledeges are expected from the receiver.
// * @param service PUS Service
// * @param subservice PUS Subservice
// */
// void initializeTcPacket(uint16_t apid, uint16_t sequenceCount, uint8_t ack, uint8_t service,
// uint8_t subservice, pus::PusVersion pusVersion, uint16_t sourceId = 0);
//
// /**
// * A pointer to a structure which defines the data structure of
// * the packet's data.
// *
// * To be hardware-safe, all elements are of byte size.
// */
// TcPacketPointer* tcData = nullptr;
// };
#endif /* FSFW_TMTCPACKET_PUS_TCPACKETPUSA_H_ */

View File

@ -1,64 +0,0 @@
#include "fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h"
#include <cstring>
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/objectmanager/frameworkObjects.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
// StorageManagerIF* TcPacketStoredBase::STORE = nullptr;
//
// TcPacketStoredBase::TcPacketStoredBase() {
// this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
// TcPacketStoredBase::checkAndSetStore();
// }
//
// TcPacketStoredBase::~TcPacketStoredBase() = default;
//
// ReturnValue_t TcPacketStoredBase::getData(const uint8_t** dataPtr, size_t* dataSize) {
// auto result = TcPacketStoredBase::STORE->getData(storeAddress, dataPtr, dataSize);
// if (result != HasReturnvaluesIF::RETURN_OK) {
//#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::warning << "TcPacketStoredBase: Could not get data" << std::endl;
//#else
// sif::printWarning("TcPacketStoredBase: Could not get data!\n");
//#endif
// }
// return result;
// }
//
// bool TcPacketStoredBase::checkAndSetStore() {
// if (TcPacketStoredBase::STORE == nullptr) {
// TcPacketStoredBase::STORE =
// ObjectManager::instance()->get<StorageManagerIF>(objects::TC_STORE); if
// (TcPacketStoredBase::STORE == nullptr) {
//#if FSFW_CPP_OSTREAM_ENABLED == 1
// sif::error << "TcPacketStoredBase::TcPacketStoredBase: TC Store not found" << std::endl;
//#else
// sif::printError("TcPacketStoredBase::TcPacketStoredBase: TC Store not found\n");
//#endif
// return false;
// }
// }
// return true;
// }
//
// void TcPacketStoredBase::setStoreAddress(store_address_t setAddress,
// RedirectableDataPointerIF* packet) {
// this->storeAddress = setAddress;
// const uint8_t* tempData = nullptr;
// size_t tempSize;
// ReturnValue_t status = StorageManagerIF::RETURN_FAILED;
// if (this->checkAndSetStore()) {
// status = TcPacketStoredBase::STORE->getData(this->storeAddress, &tempData, &tempSize);
// }
//
// if (status == StorageManagerIF::RETURN_OK) {
// packet->setData(const_cast<uint8_t*>(tempData), tempSize);
// } else {
// packet->setData(nullptr, -1);
// this->storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
// }
// }
//
// store_address_t TcPacketStoredBase::getStoreAddress() { return this->storeAddress; }

View File

@ -1,84 +0,0 @@
#ifndef TMTCPACKET_PUS_TCPACKETSTORED_H_
#define TMTCPACKET_PUS_TCPACKETSTORED_H_
#include "PusTcReader.h"
#include "TcPacketStoredIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
///**
// * Base class for telecommand packets like CFDP or PUS packets.
// * @ingroup tmtcpackets
// */
// class TcPacketStoredBase : public TcPacketStoredIF {
// public:
// /**
// * This is a default constructor which does not set the data pointer to initialize
// * with an empty cached store address
// */
// TcPacketStoredBase();
// /**
// * Constructor to set to an existing store address.
// * @param setAddress
// */
// explicit TcPacketStoredBase(store_address_t setAddress);
// /**
// * Another constructor to create a TcPacket from a raw packet stream.
// * Takes the data and adds it unchecked to the TcStore.
// * @param data Pointer to the complete TC Space Packet.
// * @param Size size of the packet.
// */
// TcPacketStoredBase(const uint8_t* data, uint32_t size);
//
// virtual ~TcPacketStoredBase();
//
// /**
// * 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) override;
//
// void setStoreAddress(store_address_t setAddress, RedirectableDataPointerIF* packet) override;
// store_address_t getStoreAddress() override;
//
// /**
// * With this call, the packet is deleted.
// * It removes itself from the store and sets its data pointer to NULL.
// * @return returncode from deleting the data.
// */
// virtual ReturnValue_t deletePacket() = 0;
//
// /**
// * This method performs a size check.
// * It reads the stored size and compares it with the size entered in the
// * packet header. This class is the optimal place for such a check as it
// * has access to both the header data and the store.
// * @return true if size is correct, false if packet is not registered in
// * store or size is incorrect.
// */
// virtual bool isSizeCorrect() = 0;
//
// 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.
// */
// static bool checkAndSetStore();
//};
#endif /* TMTCPACKET_PUS_TCPACKETSTORED_H_ */

View File

@ -1,16 +1,7 @@
#ifndef FSFW_TMTCPACKET_PUS_TM_H_
#define FSFW_TMTCPACKET_PUS_TM_H_
#include "fsfw/FSFW.h"
#if FSFW_USE_PUS_C_TELEMETRY == 1
#include "tm/TmPacketPusC.h"
#include "tm/TmPacketStoredPusC.h"
#else
#include "tm/TmPacketPusA.h"
#include "tm/TmPacketStoredPusA.h"
#endif
#include "tm/PusTmMinimal.h"
#include "tm/PusTmCreator.h"
#include "tm/PusTmReader.h"
#endif /* FSFW_TMTCPACKET_PUS_TM_H_ */

View File

@ -1,63 +0,0 @@
#include "fsfw/tmtcpacket/pus/tm/TmPacketBase.h"
#include <cstring>
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/globalfunctions/arrayprinter.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/timemanager/CCSDSTime.h"
TimeStamperIF* TmPacketBase::timeStamper = nullptr;
object_id_t TmPacketBase::timeStamperId = objects::NO_OBJECT;
TmPacketBase::TmPacketBase(uint8_t* setData) : SpacePacketReader(setData) {}
TmPacketBase::~TmPacketBase() = default;
uint16_t TmPacketBase::getSourceDataSize() {
return SpacePacketReader::getPacketDataLen() - getDataFieldSize() - CRC_SIZE + 1;
}
uint16_t TmPacketBase::getErrorControl() {
uint32_t size = getSourceDataSize() + CRC_SIZE;
uint8_t* p_to_buffer = getSourceData();
return (p_to_buffer[size - 2] << 8) + p_to_buffer[size - 1];
}
void TmPacketBase::setErrorControl() {
uint32_t full_size = getFullSize();
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
uint32_t size = getSourceDataSize();
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
getSourceData()[size + 1] = (crc)&0X00FF; // CRCL
}
ReturnValue_t TmPacketBase::getPacketTime(timeval* timestamp) const {
size_t tempSize = 0;
return CCSDSTime::convertFromCcsds(timestamp, getPacketTimeRaw(), &tempSize, getTimestampSize());
}
bool TmPacketBase::checkAndSetStamper() {
if (timeStamper == nullptr) {
timeStamper = ObjectManager::instance()->get<TimeStamperIF>(timeStamperId);
if (timeStamper == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "TmPacketBase::checkAndSetStamper: Stamper not found!" << std::endl;
#else
sif::printWarning("TmPacketBase::checkAndSetStamper: Stamper not found!\n");
#endif
return false;
}
}
return true;
}
void TmPacketBase::print() {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::info << "TmPacketBase::print:" << std::endl;
#else
sif::printInfo("TmPacketBase::print:\n");
#endif
arrayprinter::print(getWholeData(), getFullSize());
}

View File

@ -1,135 +0,0 @@
#ifndef TMTCPACKET_PUS_TMPACKETBASE_H_
#define TMTCPACKET_PUS_TMPACKETBASE_H_
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/timemanager/Clock.h"
#include "fsfw/timemanager/TimeStamperIF.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
namespace Factory {
void setStaticFrameworkObjectIds();
}
/**
* This class is the basic data handler for any ECSS PUS Telemetry packet.
*
* In addition to #SpacePacketBase, the class provides methods to handle
* the standardized entries of the PUS TM Packet Data Field Header.
* It does not contain the packet data itself but a pointer to the
* data must be set on instantiation. An invalid pointer may cause
* damage, as no getter method checks data validity. Anyway, a NULL
* check can be performed by making use of the getWholeData method.
* @ingroup tmtcpackets
*/
class TmPacketBase : public SpacePacketReader {
friend void(Factory::setStaticFrameworkObjectIds)();
public:
//! Maximum size of a TM Packet in this mission.
//! TODO: Make this dependant on a config variable.
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = 2048;
/**
* 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 set_address The position where the packet data lies.
*/
TmPacketBase(uint8_t* setData);
/**
* This is the empty default destructor.
*/
virtual ~TmPacketBase();
/**
* This is a getter for the packet's PUS Service ID, which is the second
* byte of the Data Field Header.
* @return The packet's PUS Service ID.
*/
virtual uint8_t getService() = 0;
/**
* This is a getter for the packet's PUS Service Subtype, which is the
* third byte of the Data Field Header.
* @return The packet's PUS Service Subtype.
*/
virtual uint8_t getSubService() = 0;
/**
* This is a getter for a pointer to the packet's Source data.
*
* These are the bytes that follow after the Data Field Header. They form
* the packet's source data.
* @return A pointer to the PUS Source Data.
*/
virtual uint8_t* getSourceData() = 0;
/**
* This method calculates the size of the PUS Source data field.
*
* It takes the information stored in the CCSDS Packet Data Length field
* and subtracts the Data Field Header size and the CRC size.
* @return The size of the PUS Source Data (without Error Control field)
*/
virtual uint16_t getSourceDataSize() = 0;
/**
* Get size of data field which can differ based on implementation
* @return
*/
virtual uint16_t getDataFieldSize() = 0;
virtual size_t getPacketMinimumSize() const = 0;
/**
* Interprets the "time"-field in the secondary header and returns it in
* timeval format.
* @return Converted timestamp of packet.
*/
virtual ReturnValue_t getPacketTime(timeval* timestamp) const;
/**
* Returns a raw pointer to the beginning of the time field.
* @return Raw pointer to time field.
*/
virtual uint8_t* getPacketTimeRaw() const = 0;
virtual size_t getTimestampSize() const = 0;
/**
* This is a debugging helper method that prints the whole packet content
* to the screen.
*/
void print();
/**
* With this method, the Error Control Field is updated to match the
* current content of the packet. This method is not protected because
* a recalculation by the user might be necessary when manipulating fields
* like the sequence count.
*/
void setErrorControl();
/**
* This getter returns the Error Control Field of the packet.
*
* The field is placed after any possible Source Data. If no
* Source Data is present there's still an Error Control field. It is
* supposed to be a 16bit-CRC.
* @return The PUS Error Control
*/
uint16_t getErrorControl();
protected:
/**
* The timeStamper is responsible for adding a timestamp to the packet.
* It is initialized lazy.
*/
static TimeStamperIF* timeStamper;
//! The ID to use when looking for a time stamper.
static object_id_t timeStamperId;
/**
* Checks if a time stamper is available and tries to set it if not.
* @return Returns false if setting failed.
*/
bool checkAndSetStamper();
};
#endif /* TMTCPACKET_PUS_TMPACKETBASE_H_ */

View File

@ -1,79 +0,0 @@
#include "TmPacketPusC.h"
#include <cstring>
#include "../defs.h"
#include "TmPacketBase.h"
#include "fsfw/globalfunctions/CRC.h"
#include "fsfw/globalfunctions/arrayprinter.h"
#include "fsfw/objectmanager/ObjectManagerIF.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/timemanager/CCSDSTime.h"
TmPacketPusC::TmPacketPusC(uint8_t* setData) : TmPacketBase(setData) {
tmData = reinterpret_cast<TmPacketPointerPusC*>(setData);
}
TmPacketPusC::~TmPacketPusC() = default;
uint8_t TmPacketPusC::getService() { return tmData->dataField.serviceType; }
uint8_t TmPacketPusC::getSubService() { return tmData->dataField.serviceSubtype; }
uint8_t* TmPacketPusC::getSourceData() { return &tmData->data; }
uint16_t TmPacketPusC::getSourceDataSize() {
return SpacePacketReader::getPacketDataLen() - sizeof(tmData->dataField) - CRC_SIZE + 1;
}
ReturnValue_t TmPacketPusC::setData(uint8_t* p_Data, size_t maxSize, void* args) {
ReturnValue_t result = SpacePacketReader::setData(p_Data, maxSize, args);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
if (maxSize < sizeof(TmPacketPointerPusC)) {
return HasReturnvaluesIF::RETURN_OK;
}
tmData = reinterpret_cast<TmPacketPointerPusC*>(const_cast<uint8_t*>(p_Data));
return HasReturnvaluesIF::RETURN_OK;
}
size_t TmPacketPusC::getPacketMinimumSize() const { return TM_PACKET_MIN_SIZE; }
uint16_t TmPacketPusC::getDataFieldSize() { return sizeof(PUSTmDataFieldHeaderPusC); }
uint8_t* TmPacketPusC::getPacketTimeRaw() const { return tmData->dataField.time; }
ReturnValue_t TmPacketPusC::initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice,
uint16_t packetSubcounter, uint16_t destinationId,
uint8_t timeRefField) {
// Set primary header:
ReturnValue_t result = initSpacePacketHeader(false, true, apid);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
// Set data Field Header:
// First, set to zero.
memset(&tmData->dataField, 0, sizeof(tmData->dataField));
/* Only account for last 4 bytes for time reference field */
timeRefField &= 0b1111;
tmData->dataField.versionTimeReferenceField = (ecss::PusVersion::PUS_C << 4) | timeRefField;
tmData->dataField.serviceType = service;
tmData->dataField.serviceSubtype = subservice;
tmData->dataField.subcounterMsb = (packetSubcounter << 8) & 0xff;
tmData->dataField.subcounterLsb = packetSubcounter & 0xff;
tmData->dataField.destinationIdMsb = (destinationId << 8) & 0xff;
tmData->dataField.destinationIdLsb = destinationId & 0xff;
// Timestamp packet
if (TmPacketBase::checkAndSetStamper()) {
timeStamper->addTimeStamp(tmData->dataField.time, sizeof(tmData->dataField.time));
}
return HasReturnvaluesIF::RETURN_OK;
}
void TmPacketPusC::setSourceDataSize(uint16_t size) {
setPacketDataLength(size + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
}
size_t TmPacketPusC::getTimestampSize() const { return sizeof(tmData->dataField.time); }

View File

@ -1,126 +0,0 @@
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_
#define FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_
#include "TmPacketBase.h"
#include "fsfw/objectmanager/SystemObjectIF.h"
#include "fsfw/timemanager/Clock.h"
#include "fsfw/timemanager/TimeStamperIF.h"
#include "fsfw/tmtcpacket/ccsds/SpacePacketReader.h"
namespace Factory {
void setStaticFrameworkObjectIds();
}
/**
* This struct defines a byte-wise structured PUS TM Data Field Header.
* Any optional fields in the header must be added or removed here.
* Currently, no Destination field is present, but an eigth-byte representation
* for a time tag.
* @ingroup tmtcpackets
*/
struct PUSTmDataFieldHeaderPusC {
uint8_t versionTimeReferenceField;
uint8_t serviceType;
uint8_t serviceSubtype;
uint8_t subcounterMsb;
uint8_t subcounterLsb;
uint8_t destinationIdMsb;
uint8_t destinationIdLsb;
// uint8_t time[TimeStamperIF::MISSION_TIMESTAMP_SIZE];
};
/**
* This struct defines the data structure of a PUS Telecommand Packet when
* accessed via a pointer.
* @ingroup tmtcpackets
*/
struct TmPacketPointerPusC {
ccsds::PrimaryHeader primary;
PUSTmDataFieldHeaderPusC dataField;
uint8_t data;
};
/**
* PUS A packet implementation
* @ingroup tmtcpackets
*/
class TmPacketPusC : public TmPacketBase {
friend void(Factory::setStaticFrameworkObjectIds)();
public:
/**
* This constant defines the minimum size of a valid PUS Telemetry Packet.
*/
static const uint32_t TM_PACKET_MIN_SIZE =
ccsds::HEADER_LEN + sizeof(PUSTmDataFieldHeaderPusC) + 2;
//! Maximum size of a TM Packet in this mission.
static const uint32_t MISSION_TM_PACKET_MAX_SIZE = fsfwconfig::FSFW_MAX_TM_PACKET_SIZE;
/**
* 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 set_address The position where the packet data lies.
*/
TmPacketPusC(uint8_t* setData);
/**
* This is the empty default destructor.
*/
virtual ~TmPacketPusC();
/* TmPacketBase implementations */
uint8_t getService() override;
uint8_t getSubService() override;
uint8_t* getSourceData() override;
uint16_t getSourceDataSize() override;
uint16_t getDataFieldSize() override;
/**
* Returns a raw pointer to the beginning of the time field.
* @return Raw pointer to time field.
*/
uint8_t* getPacketTimeRaw() const override;
size_t getTimestampSize() const override;
size_t getPacketMinimumSize() const override;
protected:
/**
* A pointer to a structure which defines the data structure of
* the packet's data.
*
* To be hardware-safe, all elements are of byte size.
*/
TmPacketPointerPusC* tmData;
/**
* Initializes the Tm Packet header.
* Does set the timestamp (to now), but not the error control field.
* @param apid APID used.
* @param service PUS Service
* @param subservice PUS Subservice
* @param packetSubcounter Additional subcounter used.
*/
ReturnValue_t initializeTmPacket(uint16_t apid, uint8_t service, uint8_t subservice,
uint16_t packetSubcounter, uint16_t destinationId = 0,
uint8_t timeRefField = 0);
/**
* With this method, the packet data pointer can be redirected to another
* location.
*
* This call overwrites the parent's setData method to set both its
* @c tc_data pointer and the parent's @c data pointer.
*
* @param pData A pointer to another PUS Telemetry Packet.
*/
ReturnValue_t setData(uint8_t* pData, size_t maxSize, void* args) override;
/**
* In case data was filled manually (almost never the case).
* @param size Size of source data (without CRC and data filed header!).
*/
void setSourceDataSize(uint16_t size);
};
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETPUSC_H_ */

View File

@ -1,12 +0,0 @@
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_
#define FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_
#include <FSFWConfig.h>
#if FSFW_USE_PUS_C_TELEMETRY == 1
#include "TmPacketStoredPusC.h"
#else
#include "TmPacketStoredPusA.h"
#endif
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTORED_H_ */

View File

@ -1,121 +0,0 @@
#include "fsfw/tmtcpacket/pus/tm/TmPacketStoredBase.h"
#include <cstring>
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
StorageManagerIF *TmPacketStoredBase::store = nullptr;
InternalErrorReporterIF *TmPacketStoredBase::internalErrorReporter = nullptr;
TmPacketStoredBase::TmPacketStoredBase(store_address_t setAddress) : storeAddress(setAddress) {
setStoreAddress(storeAddress);
}
TmPacketStoredBase::TmPacketStoredBase() {}
TmPacketStoredBase::~TmPacketStoredBase() {}
store_address_t TmPacketStoredBase::getStoreAddress() { return storeAddress; }
void TmPacketStoredBase::deletePacket() {
store->deleteData(storeAddress);
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
setData(nullptr, -1);
}
void TmPacketStoredBase::setStoreAddress(store_address_t setAddress) {
storeAddress = setAddress;
const uint8_t *tempData = nullptr;
size_t tempSize;
if (not checkAndSetStore()) {
return;
}
ReturnValue_t status = store->getData(storeAddress, &tempData, &tempSize);
if (status == StorageManagerIF::RETURN_OK) {
setData(const_cast<uint8_t *>(tempData), tempSize);
} else {
setData(nullptr, -1);
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
}
}
bool TmPacketStoredBase::checkAndSetStore() {
if (store == nullptr) {
store = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (store == nullptr) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::error << "TmPacketStored::TmPacketStored: TM Store not found!" << std::endl;
#endif
return false;
}
}
return true;
}
ReturnValue_t TmPacketStoredBase::sendPacket(MessageQueueId_t destination,
MessageQueueId_t sentFrom, bool doErrorReporting) {
if (getAllTmData() == nullptr) {
// SHOULDDO: More decent code.
return HasReturnvaluesIF::RETURN_FAILED;
}
TmTcMessage tmMessage(getStoreAddress());
ReturnValue_t result = MessageQueueSenderIF::sendMessage(destination, &tmMessage, sentFrom);
if (result != HasReturnvaluesIF::RETURN_OK) {
deletePacket();
if (doErrorReporting) {
checkAndReportLostTm();
}
return result;
}
// SHOULDDO: In many cases, some counter is incremented for successfully sent packets. The check
// is often not done, but just incremented.
return HasReturnvaluesIF::RETURN_OK;
}
void TmPacketStoredBase::checkAndReportLostTm() {
if (internalErrorReporter == nullptr) {
internalErrorReporter =
ObjectManager::instance()->get<InternalErrorReporterIF>(objects::INTERNAL_ERROR_REPORTER);
}
if (internalErrorReporter != nullptr) {
internalErrorReporter->lostTm();
}
}
void TmPacketStoredBase::handleStoreFailure(const char *const packetType, ReturnValue_t result,
size_t sizeToReserve) {
checkAndReportLostTm();
#if FSFW_VERBOSE_LEVEL >= 1
switch (result) {
#if FSFW_CPP_OSTREAM_ENABLED == 1
case (StorageManagerIF::DATA_STORAGE_FULL): {
sif::warning << "TmPacketStoredPus" << packetType << ": "
<< "Store full for packet with size" << sizeToReserve << std::endl;
break;
}
case (StorageManagerIF::DATA_TOO_LARGE): {
sif::warning << "TmPacketStoredPus" << packetType << ": Data with size " << sizeToReserve
<< " too large" << std::endl;
break;
}
#else
case (StorageManagerIF::DATA_STORAGE_FULL): {
sif::printWarning(
"TmPacketStoredPus%s: Store full for packet with "
"size %d\n",
packetType, sizeToReserve);
break;
}
case (StorageManagerIF::DATA_TOO_LARGE): {
sif::printWarning(
"TmPacketStoredPus%s: Data with size "
"%d too large\n",
packetType, sizeToReserve);
break;
}
#endif
}
#endif
}

View File

@ -1,86 +0,0 @@
#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_
#include "TmPacketBase.h"
#include "TmPacketStoredBase.h"
#include "fsfw/FSFW.h"
#include "fsfw/internalerror/InternalErrorReporterIF.h"
#include "fsfw/ipc/MessageQueueSenderIF.h"
#include "fsfw/serialize/SerializeIF.h"
#include "fsfw/storagemanager/StorageManagerIF.h"
/**
* This class generates a ECSS PUS Telemetry 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.
* @ingroup tmtcpackets
*/
class TmPacketStoredBase : virtual public RedirectableDataPointerIF {
public:
/**
* This is a default constructor which does not set the data pointer.
* However, it does try to set the packet store.
*/
TmPacketStoredBase(store_address_t setAddress);
TmPacketStoredBase();
virtual ~TmPacketStoredBase();
virtual uint8_t* getAllTmData() = 0;
/**
* This is a getter for the current store address of the packet.
* @return The current store address. The (raw) value is
* @c StorageManagerIF::INVALID_ADDRESS if
* the packet is not linked.
*/
store_address_t getStoreAddress();
/**
* With this call, the packet is deleted.
* It removes itself from the store and sets its data pointer to NULL.
*/
void deletePacket();
/**
* With this call, a packet can be linked to another store. This is useful
* if the packet is a class member and used for more than one packet.
* @param setAddress The new packet id to link to.
*/
void setStoreAddress(store_address_t setAddress);
ReturnValue_t sendPacket(MessageQueueId_t destination, MessageQueueId_t sentFrom,
bool doErrorReporting = true);
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::TM_STORE.
*/
static StorageManagerIF* store;
static InternalErrorReporterIF* internalErrorReporter;
/**
* 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();
void checkAndReportLostTm();
void handleStoreFailure(const char* const packetType, ReturnValue_t result, size_t sizeToReserve);
};
#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDBASE_H_ */

View File

@ -1,76 +0,0 @@
#include "fsfw/tmtcpacket/pus/tm/TmPacketStoredPusC.h"
#include <cstring>
#include "fsfw/serviceinterface/ServiceInterface.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
TmPacketStoredPusC::TmPacketStoredPusC(store_address_t setAddress)
: TmPacketStoredBase(setAddress), TmPacketPusC(nullptr) {}
TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice,
uint16_t packetSubcounter, const uint8_t *data,
uint32_t size, const uint8_t *headerData,
uint32_t headerSize, uint16_t destinationId,
uint8_t timeRefField)
: TmPacketPusC(nullptr) {
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
if (not TmPacketStoredBase::checkAndSetStore()) {
return;
}
uint8_t *pData = nullptr;
size_t sizeToReserve = getPacketMinimumSize() + size + headerSize;
ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData);
if (returnValue != store->RETURN_OK) {
handleStoreFailure("C", returnValue, sizeToReserve);
return;
}
setData(pData, sizeToReserve, nullptr);
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
memcpy(getSourceData(), headerData, headerSize);
memcpy(getSourceData() + headerSize, data, size);
setPacketDataLength(size + headerSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
}
TmPacketStoredPusC::TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice,
uint16_t packetSubcounter, SerializeIF *content,
SerializeIF *header, uint16_t destinationId,
uint8_t timeRefField)
: TmPacketPusC(nullptr) {
storeAddress.raw = StorageManagerIF::INVALID_ADDRESS;
if (not TmPacketStoredBase::checkAndSetStore()) {
return;
}
size_t sourceDataSize = 0;
if (content != nullptr) {
sourceDataSize += content->getSerializedSize();
}
if (header != nullptr) {
sourceDataSize += header->getSerializedSize();
}
uint8_t *pData = nullptr;
size_t sizeToReserve = getPacketMinimumSize() + sourceDataSize;
ReturnValue_t returnValue = store->getFreeElement(&storeAddress, sizeToReserve, &pData);
if (returnValue != store->RETURN_OK) {
handleStoreFailure("C", returnValue, sizeToReserve);
return;
}
TmPacketPusC::setData(pData, sizeToReserve, nullptr);
initializeTmPacket(apid, service, subservice, packetSubcounter, destinationId, timeRefField);
uint8_t *putDataHere = getSourceData();
size_t size = 0;
if (header != nullptr) {
header->serialize(&putDataHere, &size, sourceDataSize, SerializeIF::Endianness::BIG);
}
if (content != nullptr) {
content->serialize(&putDataHere, &size, sourceDataSize, SerializeIF::Endianness::BIG);
}
setPacketDataLength(sourceDataSize + sizeof(PUSTmDataFieldHeaderPusC) + CRC_SIZE - 1);
}
uint8_t *TmPacketStoredPusC::getAllTmData() { return getWholeData(); }
ReturnValue_t TmPacketStoredPusC::setData(uint8_t *newPointer, size_t maxSize, void *args) {
return TmPacketPusC::setData(newPointer, maxSize, args);
}

View File

@ -1,73 +0,0 @@
//#ifndef FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
//#define FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_
//
//#include "TmPacketPusC.h"
//#include "TmPacketStoredBase.h"
//
///**
// * This class generates a ECSS PUS C Telemetry 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.
// * @ingroup tmtcpackets
// */
// class TmPacketStoredPusC : public TmPacketStoredBase, public TmPacketPusC {
// public:
// /**
// * This is a default constructor which does not set the data pointer.
// * However, it does try to set the packet store.
// */
// TmPacketStoredPusC(store_address_t setAddress);
// /**
// * With this constructor, new space is allocated in the packet store and
// * a new PUS Telemetry Packet is created there.
// * Packet Application Data passed in data is copied into the packet.
// * The Application data is passed in two parts, first a header, then a
// * data field. This allows building a Telemetry Packet from two separate
// * data sources.
// * @param apid Sets the packet's APID field.
// * @param service Sets the packet's Service ID field.
// * This specifies the source service.
// * @param subservice Sets the packet's Service Subtype field.
// * This specifies the source sub-service.
// * @param packet_counter Sets the Packet counter field of this packet
// * @param data The payload data to be copied to the
// * Application Data Field
// * @param size The amount of data to be copied.
// * @param headerData The header Data of the Application field,
// * will be copied in front of data
// * @param headerSize The size of the headerDataF
// * @param destinationId Destination ID containing the application process ID as specified
// * by PUS C
// * @param timeRefField 4 bit time reference field as specified by PUS C
// */
// TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter =
// 0,
// const uint8_t* data = nullptr, uint32_t size = 0,
// const uint8_t* headerData = nullptr, uint32_t headerSize = 0,
// uint16_t destinationId = 0, uint8_t timeRefField = 0);
// /**
// * Another ctor to directly pass structured content and header data to the
// * packet to avoid additional buffers.
// */
// TmPacketStoredPusC(uint16_t apid, uint8_t service, uint8_t subservice, uint16_t packetCounter,
// SerializeIF* content, SerializeIF* header = nullptr,
// uint16_t destinationId = 0, uint8_t timeRefField = 0);
//
// uint8_t* getAllTmData() override;
//
// private:
// /**
// * Implementation required by base class
// * @param newPointer
// * @param maxSize
// * @param args
// * @return
// */
// ReturnValue_t setData(uint8_t* newPointer, size_t maxSize, void* args) override;
//};
//
//#endif /* FSFW_TMTCPACKET_PUS_TMPACKETSTOREDPUSC_H_ */

View File

@ -7,7 +7,6 @@
#include <fsfw/internalerror/InternalErrorReporter.h>
#include <fsfw/objectmanager/frameworkObjects.h>
#include <fsfw/storagemanager/PoolManager.h>
#include <fsfw/tmtcpacket/pus/tm/TmPacketStored.h>
#include <fsfw/tmtcservices/CommandingServiceBase.h>
#include <fsfw/tmtcservices/PusServiceBase.h>