From 819a2bfac49babfc6a78452bb83cd581bf902bc8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 25 Oct 2022 18:20:48 +0200 Subject: [PATCH] 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 c641eb58f..2e157efab 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 90adfa7ad..cc695babe 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 cb0d57587..cf4dbe74b 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 77801cecc..1ba94e2c2 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 3590339d2..1c2596da2 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 7bead9843..22ed3c216 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 0c5621c8b..5b421cf96 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 df21da641..0880dec65 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 940938d9d..657e0123f 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 6fa2bd1b4..670ef72fc 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 b451f4579..df4b7aa85 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 b6a524d63..515f815b6 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_ */