From 9131ca688b5071f76e141e2bd312211c5c1bf8d8 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 30 Aug 2022 15:01:10 +0200 Subject: [PATCH 01/10] make two helper functions protected --- src/fsfw/datapoollocal/LocalDataPoolManager.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/fsfw/datapoollocal/LocalDataPoolManager.h b/src/fsfw/datapoollocal/LocalDataPoolManager.h index 7db079f6d..8f369ea06 100644 --- a/src/fsfw/datapoollocal/LocalDataPoolManager.h +++ b/src/fsfw/datapoollocal/LocalDataPoolManager.h @@ -243,13 +243,14 @@ class LocalDataPoolManager : public ProvidesDataPoolSubscriptionIF, public Acces LocalDataPoolManager* getPoolManagerHandle() override; ReturnValue_t subscribeForRegularPeriodicPacket(subdp::RegularHkPeriodicParams params) override; ReturnValue_t subscribeForDiagPeriodicPacket(subdp::DiagnosticsHkPeriodicParams params) override; - ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params); ReturnValue_t subscribeForRegularUpdatePacket(subdp::RegularHkUpdateParams params) override; ReturnValue_t subscribeForDiagUpdatePacket(subdp::DiagnosticsHkUpdateParams params) override; - ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params); protected: + ReturnValue_t subscribeForPeriodicPacket(subdp::ParamsBase& params); + ReturnValue_t subscribeForUpdatePacket(subdp::ParamsBase& params); + /** Core data structure for the actual pool data */ localpool::DataPool localPoolMap; /** Every housekeeping data manager has a mutex to protect access From ebc02673ddc269f1cfdb98e061dc72c33783d3a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 08:50:39 +0200 Subject: [PATCH 02/10] provide a weak print char impl --- src/fsfw_hal/common/CMakeLists.txt | 2 ++ src/fsfw_hal/common/printChar.c | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/fsfw_hal/common/printChar.c diff --git a/src/fsfw_hal/common/CMakeLists.txt b/src/fsfw_hal/common/CMakeLists.txt index f1cfec526..1cd9c6787 100644 --- a/src/fsfw_hal/common/CMakeLists.txt +++ b/src/fsfw_hal/common/CMakeLists.txt @@ -1 +1,3 @@ add_subdirectory(gpio) + +target_sources(${LIB_FSFW_NAME} PRIVATE printChar.c) \ No newline at end of file diff --git a/src/fsfw_hal/common/printChar.c b/src/fsfw_hal/common/printChar.c new file mode 100644 index 000000000..6e02c1df9 --- /dev/null +++ b/src/fsfw_hal/common/printChar.c @@ -0,0 +1,10 @@ +#include +#include + +void __attribute__((weak)) printChar(const char* character, bool errStream) { + if (errStream) { + fprintf(stderr, "%c", *character); + } else { + printf("%c", *character); + } +} From 1e85cdadfd573052617ad25d66cbc0a67884bf10 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 08:55:33 +0200 Subject: [PATCH 03/10] remove user includes --- src/fsfw/events/Event.h | 2 -- src/fsfw/returnvalues/returnvalue.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/fsfw/events/Event.h b/src/fsfw/events/Event.h index ecab04932..e48736bff 100644 --- a/src/fsfw/events/Event.h +++ b/src/fsfw/events/Event.h @@ -4,8 +4,6 @@ #include #include "fwSubsystemIdRanges.h" -// could be moved to more suitable location -#include using EventId_t = uint16_t; using EventSeverity_t = uint8_t; diff --git a/src/fsfw/returnvalues/returnvalue.h b/src/fsfw/returnvalues/returnvalue.h index 4f9fc0924..8396cbbf7 100644 --- a/src/fsfw/returnvalues/returnvalue.h +++ b/src/fsfw/returnvalues/returnvalue.h @@ -1,8 +1,6 @@ #ifndef FSFW_RETURNVALUES_RETURNVALUE_H_ #define FSFW_RETURNVALUES_RETURNVALUE_H_ -#include - #include #include "FwClassIds.h" From 04800df31eca9755c14fdb21d68b6cfca420ce8f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 2 Sep 2022 09:04:37 +0200 Subject: [PATCH 04/10] another user-level-include --- src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h | 1 - 1 file changed, 1 deletion(-) diff --git a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h index 3250a739e..3626a2b08 100644 --- a/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h +++ b/src/fsfw_hal/devicehandlers/MgmLIS3MDLHandler.h @@ -2,7 +2,6 @@ #define MISSION_DEVICES_MGMLIS3MDLHANDLER_H_ #include "devicedefinitions/MgmLIS3HandlerDefs.h" -#include "events/subsystemIdRanges.h" #include "fsfw/devicehandlers/DeviceHandlerBase.h" #include "fsfw/globalfunctions/PeriodicOperationDivider.h" From b7a1f79d5b97ad333a3d8e20f281329ee69a0114 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 15:36:12 +0200 Subject: [PATCH 05/10] update FSFWCnfig.h --- misc/defaultcfg/fsfwconfig/FSFWConfig.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/misc/defaultcfg/fsfwconfig/FSFWConfig.h b/misc/defaultcfg/fsfwconfig/FSFWConfig.h index adf9912f9..e80abf24a 100644 --- a/misc/defaultcfg/fsfwconfig/FSFWConfig.h +++ b/misc/defaultcfg/fsfwconfig/FSFWConfig.h @@ -4,6 +4,10 @@ #include #include +// It is assumed the user has a subsystem and class ID list in some user header files. +// #include "events/subsystemIdRanges.h" +// #include "returnvalues/classIds.h" + //! Used to determine whether C++ ostreams are used which can increase //! the binary size significantly. If this is disabled, //! the C stdio functions can be used alternatively From 16688316a841ffe45909427089fe0af51dc0c81f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 5 Sep 2022 16:31:56 +0200 Subject: [PATCH 06/10] rename setBuffer to setConstBuffer --- CMakeLists.txt | 3 ++- src/fsfw/cfdp/tlv/Lv.cpp | 4 ++-- src/fsfw/cfdp/tlv/Tlv.cpp | 4 ++-- src/fsfw/pus/Service11TelecommandScheduling.tpp | 4 ++-- src/fsfw/serialize/SerialBufferAdapter.cpp | 10 +++++----- src/fsfw/serialize/SerialBufferAdapter.h | 17 +++++++++-------- src/fsfw/tmtcservices/SpacePacketParser.h | 5 +---- unittests/serialize/testSerialBufferAdapter.cpp | 3 ++- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b00a708a..3011b2449 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -360,7 +360,8 @@ if(NOT FSFW_CONFIG_PATH) if(NOT FSFW_BUILD_DOCS) message( WARNING - "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set") + "${MSG_PREFIX} Flight Software Framework configuration path FSFW_CONFIG_PATH not set" + ) message( WARNING "${MSG_PREFIX} Setting default configuration from ${DEF_CONF_PATH} ..") diff --git a/src/fsfw/cfdp/tlv/Lv.cpp b/src/fsfw/cfdp/tlv/Lv.cpp index 9c72b260e..33c0e3812 100644 --- a/src/fsfw/cfdp/tlv/Lv.cpp +++ b/src/fsfw/cfdp/tlv/Lv.cpp @@ -21,7 +21,7 @@ cfdp::Lv& cfdp::Lv::operator=(const Lv& other) { if (value == nullptr or otherSize == 0) { this->zeroLen = true; } - this->value.setBuffer(value, otherSize); + this->value.setConstBuffer(value, otherSize); return *this; } @@ -70,7 +70,7 @@ ReturnValue_t cfdp::Lv::deSerialize(const uint8_t** buffer, size_t* size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(*buffer + 1, lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; diff --git a/src/fsfw/cfdp/tlv/Tlv.cpp b/src/fsfw/cfdp/tlv/Tlv.cpp index 3a3947418..9d5f7f15c 100644 --- a/src/fsfw/cfdp/tlv/Tlv.cpp +++ b/src/fsfw/cfdp/tlv/Tlv.cpp @@ -75,7 +75,7 @@ ReturnValue_t cfdp::Tlv::deSerialize(const uint8_t **buffer, size_t *size, } zeroLen = false; // Zero-copy implementation - value.setBuffer(const_cast(*buffer + 1), lengthField); + value.setConstBuffer(*buffer + 1, lengthField); *buffer += 1 + lengthField; *size -= 1 + lengthField; return returnvalue::OK; @@ -96,7 +96,7 @@ void cfdp::Tlv::setValue(uint8_t *value, size_t len) { if (len > 0) { zeroLen = false; } - this->value.setBuffer(value, len); + this->value.setConstBuffer(value, len); } uint8_t cfdp::Tlv::getLengthField() const { return this->value.getSerializedSize() - 1; } diff --git a/src/fsfw/pus/Service11TelecommandScheduling.tpp b/src/fsfw/pus/Service11TelecommandScheduling.tpp index c82c17032..cb2f227f6 100644 --- a/src/fsfw/pus/Service11TelecommandScheduling.tpp +++ b/src/fsfw/pus/Service11TelecommandScheduling.tpp @@ -571,7 +571,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr if (result != returnvalue::OK) { return result; } - if(fromTimestamp > toTimestamp) { + if (fromTimestamp > toTimestamp) { return INVALID_TIME_WINDOW; } itBegin = telecommandMap.begin(); @@ -580,7 +580,7 @@ inline ReturnValue_t Service11TelecommandScheduling::getMapFilterFr itBegin++; } - //start looking for end beginning at begin + // start looking for end beginning at begin itEnd = itBegin; while (itEnd->first <= toTimestamp && itEnd != telecommandMap.end()) { itEnd++; diff --git a/src/fsfw/serialize/SerialBufferAdapter.cpp b/src/fsfw/serialize/SerialBufferAdapter.cpp index 81919f371..cf28d2ba2 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.cpp +++ b/src/fsfw/serialize/SerialBufferAdapter.cpp @@ -21,7 +21,7 @@ SerialBufferAdapter::SerialBufferAdapter(uint8_t* buffer, count_t buffe bufferLength(bufferLength) {} template -SerialBufferAdapter::~SerialBufferAdapter() {} +SerialBufferAdapter::~SerialBufferAdapter() = default; template ReturnValue_t SerialBufferAdapter::serialize(uint8_t** buffer, size_t* size, @@ -119,10 +119,10 @@ const uint8_t* SerialBufferAdapter::getConstBuffer() const { } template -void SerialBufferAdapter::setBuffer(uint8_t* buffer, count_t bufferLength) { - this->buffer = buffer; - this->constBuffer = buffer; - this->bufferLength = bufferLength; +void SerialBufferAdapter::setConstBuffer(const uint8_t* buf, count_t bufLen) { + this->buffer = nullptr; + this->bufferLength = bufLen; + this->constBuffer = buf; } // forward Template declaration for linker diff --git a/src/fsfw/serialize/SerialBufferAdapter.h b/src/fsfw/serialize/SerialBufferAdapter.h index 3b95fa20d..b156bb02b 100644 --- a/src/fsfw/serialize/SerialBufferAdapter.h +++ b/src/fsfw/serialize/SerialBufferAdapter.h @@ -21,6 +21,7 @@ template class SerialBufferAdapter : public SerializeIF { public: + SerialBufferAdapter() = default; /** * Constructor for constant uint8_t buffer. Length field can be serialized optionally. * Type of length can be supplied as template type. @@ -40,12 +41,12 @@ class SerialBufferAdapter : public SerializeIF { */ SerialBufferAdapter(uint8_t* buffer, count_t bufferLength, bool serializeLength = false); - virtual ~SerialBufferAdapter(); + ~SerialBufferAdapter() override; - virtual ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, - Endianness streamEndianness) const override; + ReturnValue_t serialize(uint8_t** buffer, size_t* size, size_t maxSize, + Endianness streamEndianness) const override; - virtual size_t getSerializedSize() const override; + [[nodiscard]] size_t getSerializedSize() const override; /** * @brief This function deserializes a buffer into the member buffer. @@ -59,12 +60,12 @@ class SerialBufferAdapter : public SerializeIF { * @param bigEndian * @return */ - virtual ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, - Endianness streamEndianness) override; + ReturnValue_t deSerialize(const uint8_t** buffer, size_t* size, + Endianness streamEndianness) override; uint8_t* getBuffer(); - const uint8_t* getConstBuffer() const; - void setBuffer(uint8_t* buffer, count_t bufferLength); + [[nodiscard]] const uint8_t* getConstBuffer() const; + void setConstBuffer(const uint8_t* buf, count_t bufLen); private: bool serializeLength = false; diff --git a/src/fsfw/tmtcservices/SpacePacketParser.h b/src/fsfw/tmtcservices/SpacePacketParser.h index 3a1b4d167..ea0a2feb1 100644 --- a/src/fsfw/tmtcservices/SpacePacketParser.h +++ b/src/fsfw/tmtcservices/SpacePacketParser.h @@ -17,7 +17,6 @@ */ class SpacePacketParser { public: - struct FoundPacketInfo { size_t startIdx = 0; size_t sizeFound = 0; @@ -51,9 +50,7 @@ class SpacePacketParser { ReturnValue_t parseSpacePackets(const uint8_t** buffer, const size_t maxSize, FoundPacketInfo& packetInfo); - size_t getAmountRead() { - return amountRead; - } + size_t getAmountRead() { return amountRead; } void reset() { nextStartIdx = 0; diff --git a/unittests/serialize/testSerialBufferAdapter.cpp b/unittests/serialize/testSerialBufferAdapter.cpp index e5ea379e2..abd179e46 100644 --- a/unittests/serialize/testSerialBufferAdapter.cpp +++ b/unittests/serialize/testSerialBufferAdapter.cpp @@ -64,7 +64,8 @@ TEST_CASE("Serial Buffer Adapter", "[single-file]") { SECTION("Test set buffer function") { SerialBufferAdapter tv_serial_buffer_adapter_loc = SerialBufferAdapter((uint8_t*)nullptr, 0, true); - tv_serial_buffer_adapter_loc.setBuffer(test_serial_buffer.data(), test_serial_buffer.size()); + tv_serial_buffer_adapter_loc.setConstBuffer(test_serial_buffer.data(), + test_serial_buffer.size()); serialized_size = 0; arrayPtr = testArray.data(); SerializeAdapter::serialize(&test_value_bool, &arrayPtr, &serialized_size, testArray.size(), From 07ef9a0ec3d9050f518eed7f0bf363716d0603af Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 6 Sep 2022 15:47:04 +0200 Subject: [PATCH 07/10] bump catch2 version --- CMakeLists.txt | 2 +- automation/Dockerfile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7b00a708a..36b3082b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,7 +80,7 @@ set(FSFW_CATCH2_LIB_MAJOR_VERSION 3 CACHE STRING "Catch2 library major version requirement") set(FSFW_CATCH2_LIB_VERSION - v${FSFW_CATCH2_LIB_MAJOR_VERSION}.0.0-preview5 + v${FSFW_CATCH2_LIB_MAJOR_VERSION}.1.0 CACHE STRING "Catch2 library exact version requirement") # Keep this off by default for now. See PR: diff --git a/automation/Dockerfile b/automation/Dockerfile index 2ed2a7d9a..318619f83 100644 --- a/automation/Dockerfile +++ b/automation/Dockerfile @@ -9,7 +9,7 @@ RUN apt-get --yes install gcc g++ cmake make lcov git valgrind nano iputils-ping RUN git clone https://github.com/catchorg/Catch2.git && \ cd Catch2 && \ - git checkout v3.0.0-preview5 && \ + git checkout v3.1.0 && \ cmake -Bbuild -H. -DBUILD_TESTING=OFF && \ cmake --build build/ --target install From 282704e0fd186f1f13b5ca5046f207afdf49b2f1 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 17:54:04 +0200 Subject: [PATCH 08/10] remove bsp specific code --- .../ServiceInterfaceBuffer.cpp | 91 +------------------ 1 file changed, 1 insertion(+), 90 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index dd928efee..076ab1d21 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -2,7 +2,7 @@ #if FSFW_CPP_OSTREAM_ENABLED == 1 -#include +#include #include @@ -16,8 +16,6 @@ // to be implemented by bsp extern "C" void printChar(const char*, bool errStream); -#ifndef UT699 - ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addCrToPreamble, bool buffered, bool errStream, uint16_t port) : isActive(true), @@ -168,90 +166,3 @@ void ServiceInterfaceBuffer::setAsciiColorPrefix(std::string colorPrefix) { this->colorPrefix = colorPrefix; } #endif - -#ifdef UT699 -#include "../osal/rtems/Interrupt.h" - -ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) { - this->log_message = set_message; - this->isActive = true; - setp(buf, buf + BUF_SIZE); -} - -void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { - char array[BUF_SIZE]; - uint32_t length = end - begin; - if (length > sizeof(array)) { - length = sizeof(array); - } - memcpy(array, begin, length); - - if (!Interrupt::isInterruptInProgress()) { - std::cout << array; - } else { - // Uncomment the following line if you need ISR debug output. - // printk(array); - } -} -#endif // UT699 - -#ifdef ML505 -#include -ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string set_message, uint16_t port) - : isActive(true), - log_message(set_message), - udpSocket(0), - remoteAddressLength(sizeof(remoteAddress)) { - setp(buf, buf + BUF_SIZE); - memset((uint8_t*)&remoteAddress, 0, sizeof(remoteAddress)); - remoteAddress.sin_family = AF_INET; - remoteAddress.sin_port = htons(port); - remoteAddress.sin_addr.s_addr = htonl(inet_addr("192.168.250.100")); -} - -void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { - char array[BUF_SIZE]; - uint32_t length = end - begin; - if (length > sizeof(array)) { - length = sizeof(array); - } - memcpy(array, begin, length); - - if (udpSocket <= 0) { - initSocket(); - } - - if (udpSocket > 0) { - sendto(udpSocket, array, length, 0, (sockaddr*)&remoteAddress, sizeof(remoteAddress)); - } -} - -void ServiceInterfaceBuffer::initSocket() { - sockaddr_in address; - memset((uint8_t*)&address, 0, sizeof(address)); - address.sin_family = AF_INET; - address.sin_port = htons(0); - address.sin_addr.s_addr = htonl(INADDR_ANY); - - udpSocket = socket(PF_INET, SOCK_DGRAM, 0); - if (socket < 0) { - printf("Error opening socket!\n"); - return; - } - timeval timeout = {0, 20}; - if (setsockopt(udpSocket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) { - printf("Error setting SO_RCVTIMEO socket options!\n"); - return; - } - if (setsockopt(udpSocket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) { - printf("Error setting SO_SNDTIMEO socket options!\n"); - return; - } - if (bind(udpSocket, (sockaddr*)&address, sizeof(address)) < 0) { - printf("Error binding socket!\n"); - } -} - -#endif // ML505 - -#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ From 04b619a15cd8dc7b26ccd85d78c94134828364ca Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 7 Sep 2022 17:58:49 +0200 Subject: [PATCH 09/10] update header as well --- .../ServiceInterfaceBuffer.cpp | 6 +- .../serviceinterface/ServiceInterfaceBuffer.h | 86 +------------------ 2 files changed, 5 insertions(+), 87 deletions(-) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index 076ab1d21..890912c2e 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -1,4 +1,4 @@ -#include "fsfw/serviceinterface/ServiceInterfaceBuffer.h" +#include "ServiceInterfaceBuffer.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -72,8 +72,6 @@ void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { } } -#endif - int ServiceInterfaceBuffer::overflow(int c) { if (not buffered and this->isActive) { if (c != Traits::eof()) { @@ -166,3 +164,5 @@ void ServiceInterfaceBuffer::setAsciiColorPrefix(std::string colorPrefix) { this->colorPrefix = colorPrefix; } #endif + +#endif diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h index 2ecf88d8a..682332c97 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.h @@ -1,9 +1,8 @@ #ifndef FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ #define FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ -#include - -#include "../returnvalues/returnvalue.h" +#include "fsfw/FSFW.h" +#include "fsfw/returnvalues/returnvalue.h" #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -11,8 +10,6 @@ #include #include -#ifndef UT699 - /** * @brief This is the underlying stream buffer which implements the * streambuf class and overloads the overflow() and sync() methods @@ -77,85 +74,6 @@ class ServiceInterfaceBuffer : public std::streambuf { bool crAdditionEnabled() const; }; -#endif - -#ifdef UT699 -class ServiceInterfaceBuffer : public std::basic_streambuf > { - friend class ServiceInterfaceStream; - - public: - ServiceInterfaceBuffer(std::string set_message, uint16_t port); - - protected: - bool isActive; - // This is called when buffer becomes full. If - // buffer is not used, then this is called every - // time when characters are put to stream. - virtual int overflow(int c = Traits::eof()); - - // This function is called when stream is flushed, - // for example when std::endl is put to stream. - virtual int sync(void); - - private: - // For additional message information - std::string log_message; - // For EOF detection - typedef std::char_traits Traits; - - // Work in buffer mode. It is also possible to work without buffer. - static size_t const BUF_SIZE = 128; - char buf[BUF_SIZE]; - - // In this function, the characters are parsed. - void putChars(char const* begin, char const* end); -}; -#endif // UT699 - -#ifdef ML505 -#include -#include -#include -#include -#include - -class ServiceInterfaceBuffer : public std::basic_streambuf > { - friend class ServiceInterfaceStream; - - public: - ServiceInterfaceBuffer(std::string set_message, uint16_t port); - - protected: - bool isActive; - // This is called when buffer becomes full. If - // buffer is not used, then this is called every - // time when characters are put to stream. - virtual int overflow(int c = Traits::eof()); - - // This function is called when stream is flushed, - // for example when std::endl is put to stream. - virtual int sync(void); - - private: - // For additional message information - std::string log_message; - // For EOF detection - typedef std::char_traits Traits; - - // Work in buffer mode. It is also possible to work without buffer. - static size_t const BUF_SIZE = 128; - char buf[BUF_SIZE]; - - // In this function, the characters are parsed. - void putChars(char const* begin, char const* end); - - int udpSocket; - sockaddr_in remoteAddress; - socklen_t remoteAddressLength; - void initSocket(); -}; -#endif // ML505 - #endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */ #endif /* FRAMEWORK_SERVICEINTERFACE_SERVICEINTERFACEBUFFER_H_ */ From d52f3354552371db87b881d6100dcdabc14598ce Mon Sep 17 00:00:00 2001 From: Ulrich Mohr Date: Thu, 8 Sep 2022 11:47:40 +0200 Subject: [PATCH 10/10] sif::buffer: if disabeld do not print --- src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp index dd928efee..092c234c7 100644 --- a/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp +++ b/src/fsfw/serviceinterface/ServiceInterfaceBuffer.cpp @@ -58,6 +58,9 @@ ServiceInterfaceBuffer::ServiceInterfaceBuffer(std::string setMessage, bool addC } void ServiceInterfaceBuffer::putChars(char const* begin, char const* end) { + if (not isActive) { + return; + } char array[BUF_SIZE]; uint32_t length = end - begin; if (length > sizeof(array)) {