From ec00a84b294621bded139fa76446dc7cfad8f761 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 3 Aug 2021 18:46:50 +0200 Subject: [PATCH 1/4] update README for moved logo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 484d65c07..48d2b8e7f 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -![FSFW Logo](logo/FSFW_Logo_V3_bw.png) +![FSFW Logo](misc/logo/FSFW_Logo_V3_bw.png) # Flight Software Framework (FSFW) From 2706b8fa248f9ac2516aa4a0975f629727888003 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 6 Aug 2021 11:06:33 +0200 Subject: [PATCH 2/4] Printer updates 1. Only prefix is colored now 2. Minor formatting change --- .../serviceinterface/ServiceInterfaceBuffer.cpp | 4 ++-- .../serviceinterface/ServiceInterfacePrinter.cpp | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index 25828fe38..0411e6744 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -146,8 +146,8 @@ std::string* ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) { #endif int32_t charCount = sprintf(parsePosition, - "%s: | %02" SCNu32 ":%02" SCNu32 ":%02" SCNu32 ".%03" SCNu32 " | ", - this->logMessage.c_str(), loggerTime.hour, + "%s%s | %02" SCNu32 ":%02" SCNu32 ":%02" SCNu32 ".%03" SCNu32 " | ", + this->logMessage.c_str(), sif::ANSI_COLOR_RESET, loggerTime.hour, loggerTime.minute, loggerTime.second, loggerTime.usecond /1000); diff --git a/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp b/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp index 9b62e91da..e42e515d7 100644 --- a/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfacePrinter.cpp @@ -56,25 +56,29 @@ void fsfwPrint(sif::PrintLevel printType, const char* fmt, va_list arg) { #endif if (printType == sif::PrintLevel::INFO_LEVEL) { - len += sprintf(bufferPosition + len, "INFO: "); + len += sprintf(bufferPosition + len, "INFO"); } if(printType == sif::PrintLevel::DEBUG_LEVEL) { - len += sprintf(bufferPosition + len, "DEBUG: "); + len += sprintf(bufferPosition + len, "DEBUG"); } if(printType == sif::PrintLevel::WARNING_LEVEL) { - len += sprintf(bufferPosition + len, "WARNING: "); + len += sprintf(bufferPosition + len, "WARNING"); } if(printType == sif::PrintLevel::ERROR_LEVEL) { - len += sprintf(bufferPosition + len, "ERROR: "); + len += sprintf(bufferPosition + len, "ERROR"); } +#if FSFW_COLORED_OUTPUT == 1 + len += sprintf(bufferPosition + len, sif::ANSI_COLOR_RESET); +#endif + Clock::TimeOfDay_t now; Clock::getDateAndTime(&now); /* * Log current time to terminal if desired. */ - len += sprintf(bufferPosition + len, "| %lu:%02lu:%02lu.%03lu | ", + len += sprintf(bufferPosition + len, " | %lu:%02lu:%02lu.%03lu | ", (unsigned long) now.hour, (unsigned long) now.minute, (unsigned long) now.second, From 90a1571707b4d75244ca641f0a70e2bfe9f7c764 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 6 Aug 2021 11:23:31 +0200 Subject: [PATCH 3/4] Linux HAL updates 1. The type correction was merged as part of https://egit.irs.uni-stuttgart.de/eive/fsfw/pulls/7 in the EIVE project. Quotation of PR definition of getSpiParameters is `void getSpiParameters(spi::SpiModes& spiMode, uint32_t& spiSpeed, UncommonParameters* parameters = nullptr) const;`. Here, size_t spiSpeed is passed, which implicitely gets converted to a temporary, which can not be bound to uint32_t& and, at least in gcc 9.3.0, leads to a compiler error. 2. Allow flushing the UART buffers --- hal/src/fsfw_hal/linux/spi/SpiComIF.cpp | 2 +- hal/src/fsfw_hal/linux/uart/UartComIF.cpp | 45 +++++++++++++++++++++++ hal/src/fsfw_hal/linux/uart/UartComIF.h | 15 ++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) diff --git a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp index 7273dfc27..fafe67bee 100644 --- a/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp +++ b/hal/src/fsfw_hal/linux/spi/SpiComIF.cpp @@ -82,7 +82,7 @@ ReturnValue_t SpiComIF::initializeInterface(CookieIF *cookie) { gpioComIF->pullHigh(gpioId); } - size_t spiSpeed = 0; + uint32_t spiSpeed = 0; spi::SpiModes spiMode = spi::SpiModes::MODE_0; SpiCookie::UncommonParameters params; diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp index 2b1da314e..3c9757356 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -443,6 +443,51 @@ ReturnValue_t UartComIF::readReceivedMessage(CookieIF *cookie, return RETURN_OK; } +ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF *cookie) { + std::string deviceFile; + UartDeviceMapIter uartDeviceMapIter; + UartCookie* uartCookie = dynamic_cast(cookie); + if(uartCookie == nullptr) { + sif::warning << "UartComIF::flushUartRxBuffer: Invalid uart cookie!" << std::endl; + return NULLPOINTER; + } + deviceFile = uartCookie->getDeviceFile(); + uartDeviceMapIter = uartDeviceMap.find(deviceFile); + int fd = uartDeviceMapIter->second.fileDescriptor; + tcflush(fd, TCIFLUSH); + return RETURN_OK; +} + +ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF *cookie) { + std::string deviceFile; + UartDeviceMapIter uartDeviceMapIter; + UartCookie* uartCookie = dynamic_cast(cookie); + if(uartCookie == nullptr) { + sif::warning << "UartComIF::flushUartTxBuffer: Invalid uart cookie!" << std::endl; + return NULLPOINTER; + } + deviceFile = uartCookie->getDeviceFile(); + uartDeviceMapIter = uartDeviceMap.find(deviceFile); + int fd = uartDeviceMapIter->second.fileDescriptor; + tcflush(fd, TCOFLUSH); + return RETURN_OK; +} + +ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF *cookie) { + std::string deviceFile; + UartDeviceMapIter uartDeviceMapIter; + UartCookie* uartCookie = dynamic_cast(cookie); + if(uartCookie == nullptr) { + sif::warning << "UartComIF::flushUartTxAndRxBuf: Invalid uart cookie!" << std::endl; + return NULLPOINTER; + } + deviceFile = uartCookie->getDeviceFile(); + uartDeviceMapIter = uartDeviceMap.find(deviceFile); + int fd = uartDeviceMapIter->second.fileDescriptor; + tcflush(fd, TCIOFLUSH); + return RETURN_OK; +} + void UartComIF::setUartMode(struct termios *options, UartCookie &uartCookie) { UartModes uartMode = uartCookie.getUartMode(); if(uartMode == UartModes::NON_CANONICAL) { diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.h b/hal/src/fsfw_hal/linux/uart/UartComIF.h index e513aa869..68d2b9f5f 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.h +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.h @@ -41,6 +41,21 @@ public: ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer, size_t *size) override; + /** + * @brief This function discards all data received but not read in the UART buffer. + */ + ReturnValue_t flushUartRxBuffer(CookieIF *cookie); + + /** + * @brief This function discards all data in the transmit buffer of the UART driver. + */ + ReturnValue_t flushUartTxBuffer(CookieIF *cookie); + + /** + * @brief This function discards both data in the transmit and receive buffer of the UART. + */ + ReturnValue_t flushUartTxAndRxBuf(CookieIF *cookie); + private: using UartDeviceFile_t = std::string; From 62873c31188e38ac28df369de36bb3684a371e95 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 9 Aug 2021 15:37:12 +0200 Subject: [PATCH 4/4] UartComIF check iter validity --- hal/src/fsfw_hal/linux/uart/UartComIF.cpp | 27 +++++++++++++++-------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp index 3c9757356..f52b6b1e4 100644 --- a/hal/src/fsfw_hal/linux/uart/UartComIF.cpp +++ b/hal/src/fsfw_hal/linux/uart/UartComIF.cpp @@ -453,9 +453,12 @@ ReturnValue_t UartComIF::flushUartRxBuffer(CookieIF *cookie) { } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); - int fd = uartDeviceMapIter->second.fileDescriptor; - tcflush(fd, TCIFLUSH); - return RETURN_OK; + if(uartDeviceMapIter != uartDeviceMap.end()) { + int fd = uartDeviceMapIter->second.fileDescriptor; + tcflush(fd, TCIFLUSH); + return RETURN_OK; + } + return RETURN_FAILED; } ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF *cookie) { @@ -468,9 +471,12 @@ ReturnValue_t UartComIF::flushUartTxBuffer(CookieIF *cookie) { } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); - int fd = uartDeviceMapIter->second.fileDescriptor; - tcflush(fd, TCOFLUSH); - return RETURN_OK; + if(uartDeviceMapIter != uartDeviceMap.end()) { + int fd = uartDeviceMapIter->second.fileDescriptor; + tcflush(fd, TCOFLUSH); + return RETURN_OK; + } + return RETURN_FAILED; } ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF *cookie) { @@ -483,9 +489,12 @@ ReturnValue_t UartComIF::flushUartTxAndRxBuf(CookieIF *cookie) { } deviceFile = uartCookie->getDeviceFile(); uartDeviceMapIter = uartDeviceMap.find(deviceFile); - int fd = uartDeviceMapIter->second.fileDescriptor; - tcflush(fd, TCIOFLUSH); - return RETURN_OK; + if(uartDeviceMapIter != uartDeviceMap.end()) { + int fd = uartDeviceMapIter->second.fileDescriptor; + tcflush(fd, TCIOFLUSH); + return RETURN_OK; + } + return RETURN_FAILED; } void UartComIF::setUartMode(struct termios *options, UartCookie &uartCookie) {