diff --git a/CMakeLists.txt b/CMakeLists.txt index 440d7f9b..1a8b703d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -133,7 +133,7 @@ option(FSFW_ADD_SGP4_PROPAGATOR "Add SGP4 propagator code" OFF) set(FSFW_TEST_TGT fsfw-tests) set(FSFW_DUMMY_TGT fsfw-dummy) -add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h) +add_library(${LIB_FSFW_NAME} src/fsfw/tmtcpacket/SpacePacketIF.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp src/fsfw/tmtcpacket/pus/tc/PusTcIF.h) if(IPO_SUPPORTED AND FSFW_ENABLE_IPO) set_property(TARGET ${LIB_FSFW_NAME} PROPERTY INTERPROCEDURAL_OPTIMIZATION diff --git a/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h new file mode 100644 index 00000000..91f8fe1e --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/PusTcIF.h @@ -0,0 +1,79 @@ +#ifndef FSFW_TMTCPACKET_PUSTCIF_H +#define FSFW_TMTCPACKET_PUSTCIF_H + +#include + +class PusTcIF { + public: + virtual ~PusTcIF() = default; + + /** + * This command returns the CCSDS Secondary Header Flag. + * It shall always be zero for PUS Packets. This is the + * highest bit of the first byte of the Data Field Header. + * @return the CCSDS Secondary Header Flag + */ + [[nodiscard]] virtual uint8_t getSecondaryHeaderFlag() const = 0; + /** + * This command returns the TC Packet PUS Version Number. + * The version number of ECSS PUS 2003 is 1. + * It consists of the second to fourth highest bits of the + * first byte. + * @return + */ + [[nodiscard]] virtual uint8_t getPusVersion() const = 0; + /** + * This is a getter for the packet's Ack field, which are the lowest four + * bits of the first byte of the Data Field Header. + * + * It is packed in a uint8_t variable. + * @return The packet's PUS Ack field. + */ + [[nodiscard]] virtual uint8_t getAcknowledgeFlags() const = 0; + /** + * 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. + */ + [[nodiscard]] virtual uint8_t getService() const = 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. + */ + [[nodiscard]] virtual uint8_t getSubService() const = 0; + /** + * The source ID can be used to have an additional identifier, e.g. for different ground + * station. + * @return + */ + [[nodiscard]] virtual uint16_t getSourceId() const = 0; + + /** + * This is a getter for a pointer to the packet's Application data. + * + * These are the bytes that follow after the Data Field Header. They form + * the packet's application data. + * @return A pointer to the PUS Application Data. + */ + [[nodiscard]] virtual const uint8_t* getApplicationData() const = 0; + /** + * This method calculates the size of the PUS Application 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 Application Data (without Error Control + * field) + */ + [[nodiscard]] virtual uint16_t getApplicationDataSize() const = 0; + /** + * This getter returns the Error Control Field of the packet. + * + * The field is placed after any possible Application Data. If no + * Application Data is present there's still an Error Control field. It is + * supposed to be a 16bit-CRC. + * @return The PUS Error Control + */ + [[nodiscard]] virtual uint16_t getErrorControl() const = 0; + }; +#endif // FSFW_TMTCPACKET_PUSTCIF_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp new file mode 100644 index 00000000..a93db348 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.cpp @@ -0,0 +1,3 @@ +#include "TcPacketDeserializer.h" + +TcPacketDeserializer::TcPacketDeserializer(const uint8_t *data, size_t maxSize) {} diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h new file mode 100644 index 00000000..b3b35084 --- /dev/null +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketDeserializer.h @@ -0,0 +1,14 @@ +#ifndef FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H +#define FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H + +#include "fsfw/tmtcpacket/RedirectableDataPointerIF.h" +#include "fsfw/tmtcpacket/SpacePacketIF.h" + +class TcPacketDeserializer: public SpacePacketIF, public RedirectableDataPointerIF { + public: + TcPacketDeserializer(const uint8_t* data, size_t maxSize); + private: + +}; + +#endif // FSFW_TMTCPACKET_TCPACKETDESERIALIZER_H diff --git a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h index ece0e482..4d27565a 100644 --- a/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h +++ b/src/fsfw/tmtcpacket/pus/tc/TcPacketStoredBase.h @@ -19,7 +19,7 @@ class TcPacketStoredBase : public TcPacketStoredIF { * Constructor to set to an existing store address. * @param setAddress */ - TcPacketStoredBase(store_address_t 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.