From 56e8e5a8b34dee6fcf240111618109e53b77841f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 10:39:43 +0200 Subject: [PATCH 1/9] dont know if I am going to need this --- src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h diff --git a/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h new file mode 100644 index 00000000..3590339d --- /dev/null +++ b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h @@ -0,0 +1,15 @@ +#ifndef FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_ +#define FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_ + +#include + +class TmStoreFrontendSimpleIF { +public: + virtual ~TmStoreFrontendSimpleIF() = default; +private: + virtual MessageQueueId_t getCommandQueue() const = 0; +}; + + + +#endif /* FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_ */ From 096af44e39c4a94b17ee051fbdf907ddb3026a00 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 24 Oct 2022 10:56:01 +0200 Subject: [PATCH 2/9] needs some fixing --- src/fsfw/tmstorage/TmStoreFrontendIF.h | 72 ++++++++++----------- src/fsfw/tmstorage/TmStorePackets.h | 90 ++++++++++++++------------ 2 files changed, 84 insertions(+), 78 deletions(-) diff --git a/src/fsfw/tmstorage/TmStoreFrontendIF.h b/src/fsfw/tmstorage/TmStoreFrontendIF.h index 56bcd7fa..1e3dd579 100644 --- a/src/fsfw/tmstorage/TmStoreFrontendIF.h +++ b/src/fsfw/tmstorage/TmStoreFrontendIF.h @@ -6,47 +6,12 @@ #include "fsfw/returnvalues/returnvalue.h" #include "tmStorageConf.h" -class TmPacketMinimal; -class SpacePacketBase; +class PusTmReader; +class SpacePacketReader; class TmStoreBackendIF; class TmStoreFrontendIF { public: - virtual TmStoreBackendIF* getBackend() const = 0; - - /** - * What do I need to implement here? - * This is propably used by PUS Service 15 so we should propably check for messages.. - * Provide base implementation? - * @param opCode - * @return - */ - virtual ReturnValue_t performOperation(uint8_t opCode) = 0; - /** - * Callback from the back-end to indicate a certain packet was received. - * front-end takes care of discarding/downloading the packet. - * @param packet Pointer to the newly received Space Packet. - * @param address Start address of the packet found - * @param isLastPacket Indicates if no more packets can be fetched. - * @return If more packets shall be fetched, returnvalue::OK must be returned. - * Any other code stops fetching packets. - */ - virtual ReturnValue_t packetRetrieved(TmPacketMinimal* packet, uint32_t address) = 0; - virtual void noMorePacketsInStore() = 0; - virtual void handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1 = 0, - uint32_t parameter2 = 0) = 0; - /** - * To get the queue where commands shall be sent. - * @return Id of command queue. - */ - virtual MessageQueueId_t getCommandQueue() const = 0; - virtual ReturnValue_t fetchPackets(ApidSsc start, ApidSsc end) = 0; - virtual ReturnValue_t deletePackets(ApidSsc upTo) = 0; - virtual ReturnValue_t checkPacket(SpacePacketBase* tmPacket) = 0; - virtual bool isEnabled() const = 0; - virtual void setEnabled(bool enabled) = 0; - virtual void resetDownlinkedPacketCount() = 0; - virtual ReturnValue_t setDumpTarget(object_id_t dumpTarget) = 0; static const uint8_t INTERFACE_ID = CLASS_ID::TM_STORE_FRONTEND_IF; static const ReturnValue_t BUSY = MAKE_RETURN_CODE(1); static const ReturnValue_t LAST_PACKET_FOUND = MAKE_RETURN_CODE(2); @@ -57,7 +22,38 @@ class TmStoreFrontendIF { static const ReturnValue_t ALL_DELETED = MAKE_RETURN_CODE(7); static const ReturnValue_t INVALID_DATA = MAKE_RETURN_CODE(8); static const ReturnValue_t NOT_READY = MAKE_RETURN_CODE(9); - virtual ~TmStoreFrontendIF() {} + + virtual ~TmStoreFrontendIF() = default; + + /** + * To get the queue where commands shall be sent. + * @return Id of command queue. + */ + virtual MessageQueueId_t getCommandQueue() const = 0; + + virtual TmStoreBackendIF* getBackend() const = 0; + + /** + * Callback from the back-end to indicate a certain packet was received. + * front-end takes care of discarding/downloading the packet. + * @param packet Pointer to the newly received Space Packet. + * @param address Start address of the packet found + * @param isLastPacket Indicates if no more packets can be fetched. + * @return If more packets shall be fetched, returnvalue::OK must be returned. + * Any other code stops fetching packets. + */ + virtual ReturnValue_t packetRetrieved(PusTmReader* packet, uint32_t address) = 0; + virtual void noMorePacketsInStore() = 0; + virtual void handleRetrievalFailed(ReturnValue_t errorCode, uint32_t parameter1 = 0, + uint32_t parameter2 = 0) = 0; + + virtual ReturnValue_t fetchPackets(ApidSsc start, ApidSsc end) = 0; + virtual ReturnValue_t deletePackets(ApidSsc upTo) = 0; + virtual ReturnValue_t checkPacket(SpacePacketReader* tmPacket) = 0; + virtual bool isEnabled() const = 0; + virtual void setEnabled(bool enabled) = 0; + virtual void resetDownlinkedPacketCount() = 0; + virtual ReturnValue_t setDumpTarget(object_id_t dumpTarget) = 0; }; #endif /* FSFW_TMTCSERVICES_TMSTOREFRONTENDIF_H_ */ diff --git a/src/fsfw/tmstorage/TmStorePackets.h b/src/fsfw/tmstorage/TmStorePackets.h index e519b3b7..7bead984 100644 --- a/src/fsfw/tmstorage/TmStorePackets.h +++ b/src/fsfw/tmstorage/TmStorePackets.h @@ -1,6 +1,7 @@ #ifndef FSFW_TMSTORAGE_TMSTOREPACKETS_H_ #define FSFW_TMSTORAGE_TMSTOREPACKETS_H_ +#include #include "fsfw/globalfunctions/timevalOperations.h" #include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/serialize/SerialFixedArrayListAdapter.h" @@ -11,6 +12,8 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" #include "tmStorageConf.h" +#include + class ServiceSubservice : public SerialLinkedListAdapter { public: SerializeElement service; @@ -24,7 +27,7 @@ class ServiceSubservice : public SerialLinkedListAdapter { class ApidSsc : public SerializeIF { public: - ApidSsc() : apid(SpacePacketBase::LIMIT_APID), ssc(0) {} + ApidSsc() : apid(ccsds::LIMIT_APID), ssc(0) {} ApidSsc(uint16_t apid, uint16_t ssc) : apid(apid), ssc(ssc) {} uint16_t apid; uint16_t ssc; @@ -62,51 +65,57 @@ class ChangeSelectionDefinition : public SerialLinkedListAdapter { class TmPacketInformation : public SerializeIF { public: - TmPacketInformation(TmPacketMinimal* packet) { setContent(packet); } - TmPacketInformation() - : apid(SpacePacketBase::LIMIT_APID), + TmPacketInformation(PusTmReader* packet, size_t timestampLen) + : rawTimestamp(timestampLen) { setContent(packet); } + TmPacketInformation(size_t timestampLen) + : apid(ccsds::LIMIT_APID), sourceSequenceCount(0), serviceType(0), serviceSubtype(0), - subCounter(0) {} + subCounter(0), + rawTimestamp(timestampLen) {} void reset() { - apid = SpacePacketBase::LIMIT_APID; + apid = ccsds::LIMIT_APID; sourceSequenceCount = 0; serviceType = 0; serviceSubtype = 0; subCounter = 0; - memset(rawTimestamp, 0, sizeof(rawTimestamp)); + memset(rawTimestamp.data(), 0, rawTimestamp.size()); } - void setContent(TmPacketMinimal* packet) { - apid = packet->getAPID(); - sourceSequenceCount = packet->getPacketSequenceCount(); + void setContent(PusTmReader* packet) { + apid = packet->getApid(); + sourceSequenceCount = packet->getSequenceCount(); serviceType = packet->getService(); serviceSubtype = packet->getSubService(); - subCounter = packet->getPacketSubcounter(); - memset(rawTimestamp, 0, sizeof(rawTimestamp)); - const uint8_t* pField = NULL; - uint32_t size = 0; - ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size); - if (result != returnvalue::OK) { - return; - } - if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE) { + subCounter = packet->getMessageTypeCounter(); + memset(rawTimestamp.data(), 0, rawTimestamp.size()); + // TODO: Fix all of this + //const uint8_t* pField = NULL; + //uint32_t size = 0; + //auto* timeReader = packet->getTimeReader(); + //ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size); + //if (result != returnvalue::OK) { + // return; + //} + //if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE) { // Shortcut to avoid converting CDS back and forth. - memcpy(rawTimestamp, pField, size); - return; - } - timeval time = {0, 0}; - result = packet->getPacketTime(&time); - if (result != returnvalue::OK) { - return; - } - - CCSDSTime::CDS_short cdsFormat; - result = CCSDSTime::convertToCcsds(&cdsFormat, &time); - if (result != returnvalue::OK) { - return; - } - memcpy(rawTimestamp, &cdsFormat, sizeof(cdsFormat)); + // TODO: Fix + //memcpy(rawTimestamp, pField, size); +// return; +// } +// timeval time = {0, 0}; +// result = packet->getPacketTime(&time); +// if (result != returnvalue::OK) { +// return; +// } +// +// CCSDSTime::CDS_short cdsFormat; +// result = CCSDSTime::convertToCcsds(&cdsFormat, &time); +// if (result != returnvalue::OK) { +// return; +// } + // TODO: Fix + // memcpy(rawTimestamp, &cdsFormat, sizeof(cdsFormat)); } void setContent(TmPacketInformation* content) { apid = content->apid; @@ -114,9 +123,10 @@ class TmPacketInformation : public SerializeIF { serviceType = content->serviceType; serviceSubtype = content->serviceSubtype; subCounter = content->subCounter; - memcpy(rawTimestamp, content->rawTimestamp, sizeof(rawTimestamp)); + // TODO: Fix + // memcpy(rawTimestamp, content->rawTimestamp, sizeof(rawTimestamp)); } - bool isValid() const { return (apid < SpacePacketBase::LIMIT_APID) ? true : false; } + bool isValid() const { return (apid < ccsds::LIMIT_APID) ? true : false; } static void reset(TmPacketInformation* packet) { packet->reset(); } static bool isOlderThan(const TmPacketInformation* packet, const timeval* cmpTime) { @@ -216,7 +226,7 @@ class TmPacketInformation : public SerializeIF { if (result != returnvalue::OK) { return result; } - SerialBufferAdapter adapter(rawTimestamp, sizeof(rawTimestamp)); + SerialBufferAdapter adapter(rawTimestamp.data(), rawTimestamp.size()); return adapter.serialize(buffer, size, maxSize, streamEndianness); } @@ -227,7 +237,7 @@ class TmPacketInformation : public SerializeIF { size += SerializeAdapter::getSerializedSize(&serviceType); size += SerializeAdapter::getSerializedSize(&serviceSubtype); size += SerializeAdapter::getSerializedSize(&subCounter); - SerialBufferAdapter adapter(rawTimestamp, sizeof(rawTimestamp)); + SerialBufferAdapter adapter(rawTimestamp.data(), rawTimestamp.size()); size += adapter.getSerializedSize(); return size; }; @@ -253,7 +263,7 @@ class TmPacketInformation : public SerializeIF { if (result != returnvalue::OK) { return result; } - SerialBufferAdapter adapter(rawTimestamp, sizeof(rawTimestamp)); + SerialBufferAdapter adapter(rawTimestamp.data(), rawTimestamp.size()); return adapter.deSerialize(buffer, size, streamEndianness); } @@ -263,6 +273,6 @@ class TmPacketInformation : public SerializeIF { uint8_t serviceType; uint8_t serviceSubtype; uint8_t subCounter; - uint8_t rawTimestamp[TimeStamperIF::MISSION_TIMESTAMP_SIZE]; + std::vector rawTimestamp; }; #endif /* FSFW_TMSTORAGE_TMSTOREPACKETS_H_ */ From 819a2bfac49babfc6a78452bb83cd581bf902bc8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 25 Oct 2022 18:20:48 +0200 Subject: [PATCH 3/9] add prototype for new ToAscii CCSDSTime function --- src/fsfw/devicehandlers/DeviceHandlerBase.cpp | 16 +++--- src/fsfw/globalfunctions/DleParser.cpp | 18 +++--- src/fsfw/timemanager/CCSDSTime.cpp | 5 ++ src/fsfw/timemanager/CCSDSTime.h | 2 +- src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h | 7 +-- src/fsfw/tmstorage/TmStorePackets.h | 57 ++++++++++--------- src/fsfw/tmtcservices/AcceptsTelemetryIF.h | 4 +- src/fsfw_hal/linux/uart/UartComIF.cpp | 3 +- src/fsfw_hal/linux/uart/UartComIF.h | 5 +- src/fsfw_hal/linux/uart/UartCookie.h | 4 +- src/fsfw_hal/linux/uart/helper.cpp | 6 +- src/fsfw_hal/linux/uart/helper.h | 5 +- 12 files changed, 66 insertions(+), 66 deletions(-) diff --git a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp index c641eb58..2e157efa 100644 --- a/src/fsfw/devicehandlers/DeviceHandlerBase.cpp +++ b/src/fsfw/devicehandlers/DeviceHandlerBase.cpp @@ -1603,12 +1603,12 @@ void DeviceHandlerBase::disableCommandsAndReplies() { } ReturnValue_t DeviceHandlerBase::finishAction(bool success, DeviceCommandId_t action, - ReturnValue_t result) { - auto commandIter = deviceCommandMap.find(action); - if (commandIter == deviceCommandMap.end()) { - return MessageQueueIF::NO_QUEUE; - } - commandIter->second.isExecuting = false; - actionHelper.finish(success, commandIter->second.sendReplyTo, action, result); - return returnvalue::OK; + ReturnValue_t result) { + auto commandIter = deviceCommandMap.find(action); + if (commandIter == deviceCommandMap.end()) { + return MessageQueueIF::NO_QUEUE; + } + commandIter->second.isExecuting = false; + actionHelper.finish(success, commandIter->second.sendReplyTo, action, result); + return returnvalue::OK; } diff --git a/src/fsfw/globalfunctions/DleParser.cpp b/src/fsfw/globalfunctions/DleParser.cpp index 90adfa7a..cc695bab 100644 --- a/src/fsfw/globalfunctions/DleParser.cpp +++ b/src/fsfw/globalfunctions/DleParser.cpp @@ -11,8 +11,7 @@ DleParser::DleParser(SimpleRingBuffer& decodeRingBuf, DleEncoder& decoder, BufPa : decodeRingBuf(decodeRingBuf), decoder(decoder), encodedBuf(encodedBuf), - decodedBuf(decodedBuf) { -} + decodedBuf(decodedBuf) {} ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) { if (data == nullptr or len == 0) { @@ -24,7 +23,7 @@ ReturnValue_t DleParser::passData(const uint8_t* data, size_t len) { ReturnValue_t DleParser::parseRingBuf(size_t& readSize) { ctx.setType(DleParser::ContextType::NONE); size_t availableData = decodeRingBuf.getAvailableReadData(); - if(availableData == 0) { + if (availableData == 0) { return NO_PACKET_FOUND; } if (availableData > encodedBuf.second) { @@ -106,7 +105,7 @@ void DleParser::defaultFoundPacketHandler(uint8_t* packet, size_t len, void* arg } void DleParser::defaultErrorHandler() { - if(ctx.getType() != DleParser::ContextType::ERROR) { + if (ctx.getType() != DleParser::ContextType::ERROR) { errorPrinter("No error"); return; } @@ -126,7 +125,8 @@ void DleParser::defaultErrorHandler() { case (ErrorTypes::ENCODED_BUF_TOO_SMALL): case (ErrorTypes::DECODING_BUF_TOO_SMALL): { char opt[64]; - snprintf(opt, sizeof(opt), ": Too small for packet with length %zu", ctx.decodedPacket.second); + snprintf(opt, sizeof(opt), ": Too small for packet with length %zu", + ctx.decodedPacket.second); if (ctx.error.first == ErrorTypes::ENCODED_BUF_TOO_SMALL) { errorPrinter("Encoded buf too small", opt); } else { @@ -168,10 +168,6 @@ ReturnValue_t DleParser::confirmBytesRead(size_t bytesRead) { return decodeRingBuf.deleteData(bytesRead); } -const DleParser::Context& DleParser::getContext() { - return ctx; -} +const DleParser::Context& DleParser::getContext() { return ctx; } -void DleParser::reset() { - decodeRingBuf.clear(); -} +void DleParser::reset() { decodeRingBuf.clear(); } diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index cb0d5758..cf4dbe74 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -246,6 +246,11 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* return UNSUPPORTED_TIME_FORMAT; } +ReturnValue_t CCSDSTime::convertToASCII(int8_t* to, const Clock::TimeOfDay_t* from, + uint8_t length) { + return returnvalue::OK; +} + ReturnValue_t CCSDSTime::checkCcs(const uint8_t* time, uint8_t length) { const Ccs_mseconds* time_struct = reinterpret_cast(time); diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 77801cec..1ba94e2c 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -207,7 +207,7 @@ class CCSDSTime { static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from, uint8_t length); - + static ReturnValue_t convertToASCII(int8_t *to, const Clock::TimeOfDay_t *from, uint8_t length); static uint32_t subsecondsToMicroseconds(uint16_t subseconds); private: diff --git a/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h index 3590339d..1c2596da 100644 --- a/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h +++ b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h @@ -4,12 +4,11 @@ #include class TmStoreFrontendSimpleIF { -public: + public: virtual ~TmStoreFrontendSimpleIF() = default; -private: + + private: virtual MessageQueueId_t getCommandQueue() const = 0; }; - - #endif /* FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_ */ diff --git a/src/fsfw/tmstorage/TmStorePackets.h b/src/fsfw/tmstorage/TmStorePackets.h index 7bead984..22ed3c21 100644 --- a/src/fsfw/tmstorage/TmStorePackets.h +++ b/src/fsfw/tmstorage/TmStorePackets.h @@ -2,6 +2,9 @@ #define FSFW_TMSTORAGE_TMSTOREPACKETS_H_ #include + +#include + #include "fsfw/globalfunctions/timevalOperations.h" #include "fsfw/serialize/SerialBufferAdapter.h" #include "fsfw/serialize/SerialFixedArrayListAdapter.h" @@ -12,8 +15,6 @@ #include "fsfw/tmtcpacket/pus/tm/PusTmMinimal.h" #include "tmStorageConf.h" -#include - class ServiceSubservice : public SerialLinkedListAdapter { public: SerializeElement service; @@ -65,8 +66,9 @@ class ChangeSelectionDefinition : public SerialLinkedListAdapter { class TmPacketInformation : public SerializeIF { public: - TmPacketInformation(PusTmReader* packet, size_t timestampLen) - : rawTimestamp(timestampLen) { setContent(packet); } + TmPacketInformation(PusTmReader* packet, size_t timestampLen) : rawTimestamp(timestampLen) { + setContent(packet); + } TmPacketInformation(size_t timestampLen) : apid(ccsds::LIMIT_APID), sourceSequenceCount(0), @@ -90,30 +92,31 @@ class TmPacketInformation : public SerializeIF { subCounter = packet->getMessageTypeCounter(); memset(rawTimestamp.data(), 0, rawTimestamp.size()); // TODO: Fix all of this - //const uint8_t* pField = NULL; - //uint32_t size = 0; - //auto* timeReader = packet->getTimeReader(); - //ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size); - //if (result != returnvalue::OK) { - // return; + // const uint8_t* pField = NULL; + // uint32_t size = 0; + // auto* timeReader = packet->getTimeReader(); + // ReturnValue_t result = packet->getPacketTimeRaw(&pField, &size); + // if (result != returnvalue::OK) { + // return; //} - //if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE) { - // Shortcut to avoid converting CDS back and forth. - // TODO: Fix - //memcpy(rawTimestamp, pField, size); -// return; -// } -// timeval time = {0, 0}; -// result = packet->getPacketTime(&time); -// if (result != returnvalue::OK) { -// return; -// } -// -// CCSDSTime::CDS_short cdsFormat; -// result = CCSDSTime::convertToCcsds(&cdsFormat, &time); -// if (result != returnvalue::OK) { -// return; -// } + // if (*pField == CCSDSTime::P_FIELD_CDS_SHORT && size <= TimeStamperIF::MISSION_TIMESTAMP_SIZE) + // { + // Shortcut to avoid converting CDS back and forth. + // TODO: Fix + // memcpy(rawTimestamp, pField, size); + // return; + // } + // timeval time = {0, 0}; + // result = packet->getPacketTime(&time); + // if (result != returnvalue::OK) { + // return; + // } + // + // CCSDSTime::CDS_short cdsFormat; + // result = CCSDSTime::convertToCcsds(&cdsFormat, &time); + // if (result != returnvalue::OK) { + // return; + // } // TODO: Fix // memcpy(rawTimestamp, &cdsFormat, sizeof(cdsFormat)); } diff --git a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h index 0c5621c8..5b421cf9 100644 --- a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h @@ -23,7 +23,9 @@ class AcceptsTelemetryIF { */ [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const = 0; - [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const { return getReportReceptionQueue(0); } + [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const { + return getReportReceptionQueue(0); + } }; #endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */ diff --git a/src/fsfw_hal/linux/uart/UartComIF.cpp b/src/fsfw_hal/linux/uart/UartComIF.cpp index df21da64..0880dec6 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -1,4 +1,5 @@ #include "UartComIF.h" + #include #include #include @@ -458,5 +459,3 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF* cookie) { } return returnvalue::FAILED; } - - diff --git a/src/fsfw_hal/linux/uart/UartComIF.h b/src/fsfw_hal/linux/uart/UartComIF.h index 940938d9..657e0123 100644 --- a/src/fsfw_hal/linux/uart/UartComIF.h +++ b/src/fsfw_hal/linux/uart/UartComIF.h @@ -1,15 +1,14 @@ #ifndef BSP_Q7S_COMIF_UARTCOMIF_H_ #define BSP_Q7S_COMIF_UARTCOMIF_H_ -#include "UartCookie.h" -#include "helper.h" - #include #include #include #include +#include "UartCookie.h" +#include "helper.h" /** * @brief This is the communication interface to access serial ports on linux based operating diff --git a/src/fsfw_hal/linux/uart/UartCookie.h b/src/fsfw_hal/linux/uart/UartCookie.h index 6fa2bd1b..670ef72f 100644 --- a/src/fsfw_hal/linux/uart/UartCookie.h +++ b/src/fsfw_hal/linux/uart/UartCookie.h @@ -1,14 +1,12 @@ #ifndef SAM9G20_COMIF_COOKIES_UART_COOKIE_H_ #define SAM9G20_COMIF_COOKIES_UART_COOKIE_H_ -#include "helper.h" - #include #include #include - +#include "helper.h" /** * @brief Cookie for the UartComIF. There are many options available to configure the UART driver. diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp index b451f457..df4b7aa8 100644 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ b/src/fsfw_hal/linux/uart/helper.cpp @@ -1,8 +1,9 @@ #include "helper.h" -#include "fsfw/serviceinterface.h" #include +#include "fsfw/serviceinterface.h" + void uart::setMode(struct termios& options, UartModes mode) { if (mode == UartModes::NON_CANONICAL) { /* Disable canonical mode */ @@ -145,6 +146,5 @@ void uart::setBaudrate(struct termios& options, UartBaudRate baud) { } int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) { - return ioctl(serialPort, TIOCGICOUNT, &icounter); + return ioctl(serialPort, TIOCGICOUNT, &icounter); } - diff --git a/src/fsfw_hal/linux/uart/helper.h b/src/fsfw_hal/linux/uart/helper.h index b6a524d6..515f815b 100644 --- a/src/fsfw_hal/linux/uart/helper.h +++ b/src/fsfw_hal/linux/uart/helper.h @@ -1,8 +1,8 @@ #ifndef FSFW_HAL_LINUX_UART_HELPER_H_ #define FSFW_HAL_LINUX_UART_HELPER_H_ -#include #include +#include enum class Parity { NONE, EVEN, ODD }; @@ -56,7 +56,6 @@ void setBaudrate(struct termios& options, UartBaudRate baud); int readCountersAndErrors(int serialPort, serial_icounter_struct& icounter); -} - +} // namespace uart #endif /* FSFW_HAL_LINUX_UART_HELPER_H_ */ From 0303c1a8853f423dc9ff2ba12e9e56351aa00961 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 11:31:22 +0100 Subject: [PATCH 4/9] remove file --- src/fsfw_hal/linux/uart/helper.cpp | 150 ----------------------------- 1 file changed, 150 deletions(-) delete mode 100644 src/fsfw_hal/linux/uart/helper.cpp diff --git a/src/fsfw_hal/linux/uart/helper.cpp b/src/fsfw_hal/linux/uart/helper.cpp deleted file mode 100644 index df4b7aa8..00000000 --- a/src/fsfw_hal/linux/uart/helper.cpp +++ /dev/null @@ -1,150 +0,0 @@ -#include "helper.h" - -#include - -#include "fsfw/serviceinterface.h" - -void uart::setMode(struct termios& options, UartModes mode) { - if (mode == UartModes::NON_CANONICAL) { - /* Disable canonical mode */ - options.c_lflag &= ~ICANON; - } else if (mode == UartModes::CANONICAL) { - options.c_lflag |= ICANON; - } -} - -void uart::setBaudrate(struct termios& options, UartBaudRate baud) { - switch (baud) { - case UartBaudRate::RATE_50: - cfsetispeed(&options, B50); - cfsetospeed(&options, B50); - break; - case UartBaudRate::RATE_75: - cfsetispeed(&options, B75); - cfsetospeed(&options, B75); - break; - case UartBaudRate::RATE_110: - cfsetispeed(&options, B110); - cfsetospeed(&options, B110); - break; - case UartBaudRate::RATE_134: - cfsetispeed(&options, B134); - cfsetospeed(&options, B134); - break; - case UartBaudRate::RATE_150: - cfsetispeed(&options, B150); - cfsetospeed(&options, B150); - break; - case UartBaudRate::RATE_200: - cfsetispeed(&options, B200); - cfsetospeed(&options, B200); - break; - case UartBaudRate::RATE_300: - cfsetispeed(&options, B300); - cfsetospeed(&options, B300); - break; - case UartBaudRate::RATE_600: - cfsetispeed(&options, B600); - cfsetospeed(&options, B600); - break; - case UartBaudRate::RATE_1200: - cfsetispeed(&options, B1200); - cfsetospeed(&options, B1200); - break; - case UartBaudRate::RATE_1800: - cfsetispeed(&options, B1800); - cfsetospeed(&options, B1800); - break; - case UartBaudRate::RATE_2400: - cfsetispeed(&options, B2400); - cfsetospeed(&options, B2400); - break; - case UartBaudRate::RATE_4800: - cfsetispeed(&options, B4800); - cfsetospeed(&options, B4800); - break; - case UartBaudRate::RATE_9600: - cfsetispeed(&options, B9600); - cfsetospeed(&options, B9600); - break; - case UartBaudRate::RATE_19200: - cfsetispeed(&options, B19200); - cfsetospeed(&options, B19200); - break; - case UartBaudRate::RATE_38400: - cfsetispeed(&options, B38400); - cfsetospeed(&options, B38400); - break; - case UartBaudRate::RATE_57600: - cfsetispeed(&options, B57600); - cfsetospeed(&options, B57600); - break; - case UartBaudRate::RATE_115200: - cfsetispeed(&options, B115200); - cfsetospeed(&options, B115200); - break; - case UartBaudRate::RATE_230400: - cfsetispeed(&options, B230400); - cfsetospeed(&options, B230400); - break; -#ifndef __APPLE__ - case UartBaudRate::RATE_460800: - cfsetispeed(&options, B460800); - cfsetospeed(&options, B460800); - break; - case UartBaudRate::RATE_500000: - cfsetispeed(&options, B500000); - cfsetospeed(&options, B500000); - break; - case UartBaudRate::RATE_576000: - cfsetispeed(&options, B576000); - cfsetospeed(&options, B576000); - break; - case UartBaudRate::RATE_921600: - cfsetispeed(&options, B921600); - cfsetospeed(&options, B921600); - break; - case UartBaudRate::RATE_1000000: - cfsetispeed(&options, B1000000); - cfsetospeed(&options, B1000000); - break; - case UartBaudRate::RATE_1152000: - cfsetispeed(&options, B1152000); - cfsetospeed(&options, B1152000); - break; - case UartBaudRate::RATE_1500000: - cfsetispeed(&options, B1500000); - cfsetospeed(&options, B1500000); - break; - case UartBaudRate::RATE_2000000: - cfsetispeed(&options, B2000000); - cfsetospeed(&options, B2000000); - break; - case UartBaudRate::RATE_2500000: - cfsetispeed(&options, B2500000); - cfsetospeed(&options, B2500000); - break; - case UartBaudRate::RATE_3000000: - cfsetispeed(&options, B3000000); - cfsetospeed(&options, B3000000); - break; - case UartBaudRate::RATE_3500000: - cfsetispeed(&options, B3500000); - cfsetospeed(&options, B3500000); - break; - case UartBaudRate::RATE_4000000: - cfsetispeed(&options, B4000000); - cfsetospeed(&options, B4000000); - break; -#endif // ! __APPLE__ - default: -#if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::warning << "UartComIF::configureBaudrate: Baudrate not supported" << std::endl; -#endif - break; - } -} - -int uart::readCountersAndErrors(int serialPort, serial_icounter_struct& icounter) { - return ioctl(serialPort, TIOCGICOUNT, &icounter); -} From 61fd5d1b62fe3149b193c6c4175cb9b57cbe67f1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 14:12:42 +0100 Subject: [PATCH 5/9] impl function to generate ASCII timestamp sec accuracy --- src/fsfw/timemanager/CCSDSTime.cpp | 15 +++++++++++++-- src/fsfw/timemanager/CCSDSTime.h | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index cf4dbe74..535b18a2 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -246,8 +246,19 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* return UNSUPPORTED_TIME_FORMAT; } -ReturnValue_t CCSDSTime::convertToASCII(int8_t* to, const Clock::TimeOfDay_t* from, - uint8_t length) { +ReturnValue_t CCSDSTime::convertToAsciiWithSecs(int8_t* to, const Clock::TimeOfDay_t* from, + uint8_t length) { + if(from == nullptr or to == nullptr) { + return returnvalue::FAILED; + } + int count = snprintf(reinterpret_cast(to), length, + "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 + "T%" + "2" SCNu32 ":%2" SCNu32 ":%2" SCNu32, + from->year, from->month, from->day, from->hour, from->minute, from->second); + if(count >= length) { + return returnvalue::FAILED; + } return returnvalue::OK; } diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 1ba94e2c..0d4b6e61 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -207,7 +207,7 @@ class CCSDSTime { static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from, uint8_t length); - static ReturnValue_t convertToASCII(int8_t *to, const Clock::TimeOfDay_t *from, uint8_t length); + static ReturnValue_t convertToAsciiWithSecs(int8_t *to, const Clock::TimeOfDay_t *from, uint8_t length); static uint32_t subsecondsToMicroseconds(uint16_t subseconds); private: From 2b6a33e718f896300ca08345a9211c2ae974d014 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 11 Nov 2022 14:13:46 +0100 Subject: [PATCH 6/9] afmt --- src/fsfw/timemanager/CCSDSTime.cpp | 12 +++++------- src/fsfw/timemanager/CCSDSTime.h | 3 ++- src/fsfw_hal/linux/serial/SerialCookie.cpp | 2 +- src/fsfw_hal/linux/serial/SerialCookie.h | 2 +- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/fsfw/timemanager/CCSDSTime.cpp b/src/fsfw/timemanager/CCSDSTime.cpp index 535b18a2..7ca1f7f1 100644 --- a/src/fsfw/timemanager/CCSDSTime.cpp +++ b/src/fsfw/timemanager/CCSDSTime.cpp @@ -247,16 +247,14 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t* } ReturnValue_t CCSDSTime::convertToAsciiWithSecs(int8_t* to, const Clock::TimeOfDay_t* from, - uint8_t length) { - if(from == nullptr or to == nullptr) { + uint8_t length) { + if (from == nullptr or to == nullptr) { return returnvalue::FAILED; } int count = snprintf(reinterpret_cast(to), length, - "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 - "T%" - "2" SCNu32 ":%2" SCNu32 ":%2" SCNu32, - from->year, from->month, from->day, from->hour, from->minute, from->second); - if(count >= length) { + "%4" SCNu32 "-%2" SCNu32 "-%2" SCNu32 "T%2" SCNu32 ":%2" SCNu32 ":%2" SCNu32, + from->year, from->month, from->day, from->hour, from->minute, from->second); + if (count >= length) { return returnvalue::FAILED; } return returnvalue::OK; diff --git a/src/fsfw/timemanager/CCSDSTime.h b/src/fsfw/timemanager/CCSDSTime.h index 0d4b6e61..03a8ea8f 100644 --- a/src/fsfw/timemanager/CCSDSTime.h +++ b/src/fsfw/timemanager/CCSDSTime.h @@ -207,7 +207,8 @@ class CCSDSTime { static ReturnValue_t convertFromASCII(Clock::TimeOfDay_t *to, uint8_t const *from, uint8_t length); - static ReturnValue_t convertToAsciiWithSecs(int8_t *to, const Clock::TimeOfDay_t *from, uint8_t length); + static ReturnValue_t convertToAsciiWithSecs(int8_t *to, const Clock::TimeOfDay_t *from, + uint8_t length); static uint32_t subsecondsToMicroseconds(uint16_t subseconds); private: diff --git a/src/fsfw_hal/linux/serial/SerialCookie.cpp b/src/fsfw_hal/linux/serial/SerialCookie.cpp index e85d339d..1b7e9b51 100644 --- a/src/fsfw_hal/linux/serial/SerialCookie.cpp +++ b/src/fsfw_hal/linux/serial/SerialCookie.cpp @@ -3,7 +3,7 @@ #include SerialCookie::SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, - size_t maxReplyLen, UartModes uartMode) + size_t maxReplyLen, UartModes uartMode) : handlerId(handlerId), deviceFile(deviceFile), uartMode(uartMode), diff --git a/src/fsfw_hal/linux/serial/SerialCookie.h b/src/fsfw_hal/linux/serial/SerialCookie.h index 3916e4ca..7a9c0eca 100644 --- a/src/fsfw_hal/linux/serial/SerialCookie.h +++ b/src/fsfw_hal/linux/serial/SerialCookie.h @@ -30,7 +30,7 @@ class SerialCookie : public CookieIF { * One stop bit */ SerialCookie(object_id_t handlerId, std::string deviceFile, UartBaudRate baudrate, - size_t maxReplyLen, UartModes uartMode = UartModes::NON_CANONICAL); + size_t maxReplyLen, UartModes uartMode = UartModes::NON_CANONICAL); virtual ~SerialCookie(); From 2aa4af69742d932f09ec2a1d3d29b648295035d1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 14 Dec 2022 13:50:57 +0100 Subject: [PATCH 7/9] make function public --- src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h index 1c2596da..2b23b281 100644 --- a/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h +++ b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h @@ -7,8 +7,8 @@ class TmStoreFrontendSimpleIF { public: virtual ~TmStoreFrontendSimpleIF() = default; - private: virtual MessageQueueId_t getCommandQueue() const = 0; + private: }; #endif /* FSFW_SRC_FSFW_TMSTORAGE_TMSTOREBACKENDSIMPLEIF_H_ */ From 06dca7608ae50d80f648450e21186e489c75fc8d Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 7 Feb 2023 12:06:34 +0100 Subject: [PATCH 8/9] time stamper empty ctor --- src/fsfw/timemanager/CdsShortTimeStamper.cpp | 2 ++ src/fsfw/timemanager/CdsShortTimeStamper.h | 1 + src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h | 1 + 3 files changed, 4 insertions(+) diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.cpp b/src/fsfw/timemanager/CdsShortTimeStamper.cpp index 8fb33f12..aa259029 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.cpp +++ b/src/fsfw/timemanager/CdsShortTimeStamper.cpp @@ -4,6 +4,8 @@ #include "fsfw/timemanager/Clock.h" +CdsShortTimeStamper::CdsShortTimeStamper() : SystemObject(0, false) {} + CdsShortTimeStamper::CdsShortTimeStamper(object_id_t objectId) : SystemObject(objectId) {} ReturnValue_t CdsShortTimeStamper::serialize(uint8_t **buffer, size_t *size, size_t maxSize, diff --git a/src/fsfw/timemanager/CdsShortTimeStamper.h b/src/fsfw/timemanager/CdsShortTimeStamper.h index 244d54b6..a16a07b6 100644 --- a/src/fsfw/timemanager/CdsShortTimeStamper.h +++ b/src/fsfw/timemanager/CdsShortTimeStamper.h @@ -18,6 +18,7 @@ class CdsShortTimeStamper : public TimeWriterIF, public TimeReaderIF, public SystemObject { public: static constexpr size_t TIMESTAMP_LEN = 7; + CdsShortTimeStamper(); /** * @brief Default constructor which also registers the time stamper as a * system object so it can be found with the #objectManager. diff --git a/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h index 2b23b281..5089f37d 100644 --- a/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h +++ b/src/fsfw/tmstorage/TmStoreFrontendSimpleIF.h @@ -8,6 +8,7 @@ class TmStoreFrontendSimpleIF { virtual ~TmStoreFrontendSimpleIF() = default; virtual MessageQueueId_t getCommandQueue() const = 0; + private: }; From 2a0c244468e40c4d036a2c4d5eeec3af03a2f064 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 20 Feb 2023 16:10:21 +0100 Subject: [PATCH 9/9] add pus 15 store ID --- src/fsfw/objectmanager/frameworkObjects.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fsfw/objectmanager/frameworkObjects.h b/src/fsfw/objectmanager/frameworkObjects.h index 9487147d..bf153cae 100644 --- a/src/fsfw/objectmanager/frameworkObjects.h +++ b/src/fsfw/objectmanager/frameworkObjects.h @@ -15,6 +15,7 @@ enum framework_objects : object_id_t { PUS_SERVICE_8_FUNCTION_MGMT = 0x53000008, PUS_SERVICE_9_TIME_MGMT = 0x53000009, PUS_SERVICE_11_TC_SCHEDULER = 0x53000011, + PUS_SERVICE_15_TM_STORAGE = 0x53000015, PUS_SERVICE_17_TEST = 0x53000017, PUS_SERVICE_20_PARAMETERS = 0x53000020, PUS_SERVICE_200_MODE_MGMT = 0x53000200,