From fe3d6bd4320ca12e53c11feb7448aa181b5f66a6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 10:56:46 +0100 Subject: [PATCH 01/10] uio able to resolve symlinks now --- src/fsfw_hal/linux/uio/UioMapper.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index 3d7e5987e..e34c209a5 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -1,6 +1,7 @@ #include "UioMapper.h" #include +#include #include #include @@ -13,7 +14,23 @@ const char UioMapper::UIO_PATH_PREFIX[] = "/sys/class/uio/"; const char UioMapper::MAP_SUBSTR[] = "/maps/map"; const char UioMapper::SIZE_FILE_PATH[] = "/size"; -UioMapper::UioMapper(std::string uioFile, int mapNum) : uioFile(uioFile), mapNum(mapNum) {} +UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) { + struct stat buf; + lstat(uioFile.c_str(), &buf); + if (S_ISLNK(buf.st_mode)) { + char* res = realpath(uioFile.c_str(), nullptr); + if (res) { + this->uioFile = res; + } else { +#if FSFW_CPP_OSTREAM_ENABLED == 1 + sif::error << "Could not resolve real path of UIO file " << uioFile << std::endl; +#endif + } + free(res); + } else { + this->uioFile = std::move(uioFile); + } +} UioMapper::~UioMapper() {} @@ -22,7 +39,7 @@ ReturnValue_t UioMapper::getMappedAdress(uint32_t** address, Permissions permiss int fd = open(uioFile.c_str(), O_RDWR); if (fd < 1) { #if FSFW_CPP_OSTREAM_ENABLED == 1 - sif::error << "PtmeAxiConfig::initialize: Invalid UIO device file" << std::endl; + sif::error << "UioMapper::getMappedAdress: Invalid UIO device file " << uioFile << std::endl; #endif return returnvalue::FAILED; } From 8fe8d810e977e88b3ce22a2f4332527892457377 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:27:31 +0100 Subject: [PATCH 02/10] only delete table if not nullptr --- src/fsfw/health/HealthHelper.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/fsfw/health/HealthHelper.cpp b/src/fsfw/health/HealthHelper.cpp index bf1a92d2e..f6077ea15 100644 --- a/src/fsfw/health/HealthHelper.cpp +++ b/src/fsfw/health/HealthHelper.cpp @@ -5,7 +5,11 @@ HealthHelper::HealthHelper(HasHealthIF* owner, object_id_t objectId) : objectId(objectId), owner(owner) {} -HealthHelper::~HealthHelper() { healthTable->removeObject(objectId); } +HealthHelper::~HealthHelper() { + if (healthTable != nullptr) { + healthTable->removeObject(objectId); + } +} ReturnValue_t HealthHelper::handleHealthCommand(CommandMessage* message) { switch (message->getCommand()) { From 03620970e2e883c9dc3da8c617e73935596bafc6 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:38:32 +0100 Subject: [PATCH 03/10] function to get queue is const now --- src/fsfw/tmtcservices/AcceptsTelemetryIF.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h index c3e3eff38..5b421cf96 100644 --- a/src/fsfw/tmtcservices/AcceptsTelemetryIF.h +++ b/src/fsfw/tmtcservices/AcceptsTelemetryIF.h @@ -21,9 +21,11 @@ class AcceptsTelemetryIF { * receiving message queue. * @return The telemetry reception message queue id. */ - virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) = 0; + [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const = 0; - virtual MessageQueueId_t getReportReceptionQueue() { return getReportReceptionQueue(0); } + [[nodiscard]] virtual MessageQueueId_t getReportReceptionQueue() const { + return getReportReceptionQueue(0); + } }; #endif /* FSFW_TMTCSERVICES_ACCEPTSTELEMETRYIF_H_ */ From a236a5ec507a0be1f6e8a5ef5821ec71942e8a04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:40:26 +0100 Subject: [PATCH 04/10] adaptions for AcceptsTelemetryIF --- src/fsfw/tmtcservices/TmTcBridge.cpp | 2 +- src/fsfw/tmtcservices/TmTcBridge.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw/tmtcservices/TmTcBridge.cpp b/src/fsfw/tmtcservices/TmTcBridge.cpp index 0e9f0da40..f22d70d64 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.cpp +++ b/src/fsfw/tmtcservices/TmTcBridge.cpp @@ -240,7 +240,7 @@ void TmTcBridge::registerCommDisconnect() { } } -MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) { +MessageQueueId_t TmTcBridge::getReportReceptionQueue(uint8_t virtualChannel) const { return tmTcReceptionQueue->getId(); } diff --git a/src/fsfw/tmtcservices/TmTcBridge.h b/src/fsfw/tmtcservices/TmTcBridge.h index 4b90d1d52..ed4d254e7 100644 --- a/src/fsfw/tmtcservices/TmTcBridge.h +++ b/src/fsfw/tmtcservices/TmTcBridge.h @@ -65,7 +65,7 @@ class TmTcBridge : public AcceptsTelemetryIF, ReturnValue_t performOperation(uint8_t operationCode = 0) override; /** AcceptsTelemetryIF override */ - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel = 0) override; + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; /** AcceptsTelecommandsIF override */ uint32_t getIdentifier() const override; From d31a5306f0ddf27bd0ecf2315c03f97df0cf0865 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:41:03 +0100 Subject: [PATCH 05/10] fix mock --- unittests/mocks/AcceptsTmMock.cpp | 2 +- unittests/mocks/AcceptsTmMock.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/unittests/mocks/AcceptsTmMock.cpp b/unittests/mocks/AcceptsTmMock.cpp index 7b9970478..2f718e61b 100644 --- a/unittests/mocks/AcceptsTmMock.cpp +++ b/unittests/mocks/AcceptsTmMock.cpp @@ -6,7 +6,7 @@ AcceptsTmMock::AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToR AcceptsTmMock::AcceptsTmMock(MessageQueueId_t queueToReturn) : SystemObject(objects::NO_OBJECT, false), returnedQueue(queueToReturn) {} -MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) { +MessageQueueId_t AcceptsTmMock::getReportReceptionQueue(uint8_t virtualChannel) const { return returnedQueue; } diff --git a/unittests/mocks/AcceptsTmMock.h b/unittests/mocks/AcceptsTmMock.h index d6cc7f85d..b12e1094a 100644 --- a/unittests/mocks/AcceptsTmMock.h +++ b/unittests/mocks/AcceptsTmMock.h @@ -9,7 +9,7 @@ class AcceptsTmMock : public SystemObject, public AcceptsTelemetryIF { AcceptsTmMock(object_id_t registeredId, MessageQueueId_t queueToReturn); explicit AcceptsTmMock(MessageQueueId_t queueToReturn); - MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) override; + MessageQueueId_t getReportReceptionQueue(uint8_t virtualChannel) const override; const char* getName() const override; MessageQueueId_t returnedQueue; From cbc8dbcdd4c931b5f19f9c5a452e4b12147ce036 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:44:45 +0100 Subject: [PATCH 06/10] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e2..bfecc6858 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Changes +- `AcceptsTelemetryIF`: `getReportReceptionQueue` is const now + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/712 - Remove default secondary header argument for `uint16_t getTcSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` and `uint16_t getTmSpacePacketIdFromApid(uint16_t apid, bool secondaryHeaderFlag)` From f8c07ec9cf2589547f4a706f0651557a6a689943 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:46:43 +0100 Subject: [PATCH 07/10] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e2..9545c63ee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Fixes +- Only delete health table entry in `HealthHelper` destructor if + health table was set. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/710/files - I2C Bugfixes: Do not keep iterator as member and fix some incorrect handling with the iterator. Also properly reset the reply size for successfull transfers and erroneous transfers. PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/700 From 3bc3da5a8d3f534b3bc74af4e840dabd277db5ad Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 15 Nov 2022 11:47:26 +0100 Subject: [PATCH 08/10] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c7ab45e2..0f4a9e3a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Added +- `UioMapper` is able to resolve symlinks now. + PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/709 - Add new `UnsignedByteField` class PR: https://egit.irs.uni-stuttgart.de/fsfw/fsfw/pulls/660 From 65a5abab495ad07f5aca25f27569537fea6a577a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Nov 2022 14:56:08 +0100 Subject: [PATCH 09/10] move free call --- CMakeLists.txt | 12 +++++++++--- src/fsfw/storagemanager/StorageManagerIF.h | 3 ++- src/fsfw_hal/linux/serial/SerialCookie.cpp | 2 +- src/fsfw_hal/linux/serial/SerialCookie.h | 2 +- src/fsfw_hal/linux/uio/UioMapper.cpp | 6 +++--- unittests/hal/CMakeLists.txt | 4 +--- unittests/mocks/cfdp/FaultHandlerMock.h | 2 +- 7 files changed, 18 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd01510e0..8308f5234 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -346,9 +346,15 @@ if(FSFW_BUILD_TESTS) DEPENDENCIES ${FSFW_TEST_TGT}) else() setup_target_for_coverage_lcov( - NAME ${FSFW_TEST_TGT}_coverage EXECUTABLE ${FSFW_TEST_TGT} - DEPENDENCIES ${FSFW_TEST_TGT} - GENHTML_ARGS --html-epilog ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) + NAME + ${FSFW_TEST_TGT}_coverage + EXECUTABLE + ${FSFW_TEST_TGT} + DEPENDENCIES + ${FSFW_TEST_TGT} + GENHTML_ARGS + --html-epilog + ${CMAKE_SOURCE_DIR}/unittests/lcov_epilog.html) endif() endif() endif() diff --git a/src/fsfw/storagemanager/StorageManagerIF.h b/src/fsfw/storagemanager/StorageManagerIF.h index f9fb33f5f..e48e19dbb 100644 --- a/src/fsfw/storagemanager/StorageManagerIF.h +++ b/src/fsfw/storagemanager/StorageManagerIF.h @@ -181,7 +181,8 @@ class StorageManagerIF { * @return Returns @returnvalue::OK if data was added. * @returnvalue::FAILED if data could not be added, storageId is unchanged then. */ - virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, uint8_t** dataPtr) = 0; + virtual ReturnValue_t getFreeElement(store_address_t* storageId, size_t size, + uint8_t** dataPtr) = 0; [[nodiscard]] virtual bool hasDataAtId(store_address_t storeId) const = 0; diff --git a/src/fsfw_hal/linux/serial/SerialCookie.cpp b/src/fsfw_hal/linux/serial/SerialCookie.cpp index e85d339d1..1b7e9b511 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 3916e4caf..7a9c0eca5 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(); diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index e34c209a5..9e16ce67e 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -20,15 +20,15 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) { if (S_ISLNK(buf.st_mode)) { char* res = realpath(uioFile.c_str(), nullptr); if (res) { - this->uioFile = res; + uioFile = res; + free(res); } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Could not resolve real path of UIO file " << uioFile << std::endl; #endif } - free(res); } else { - this->uioFile = std::move(uioFile); + uioFile = std::move(uioFile); } } diff --git a/unittests/hal/CMakeLists.txt b/unittests/hal/CMakeLists.txt index 2a6c012bf..76aabd51a 100644 --- a/unittests/hal/CMakeLists.txt +++ b/unittests/hal/CMakeLists.txt @@ -1,7 +1,5 @@ target_sources(${FSFW_TEST_TGT} PRIVATE testHostFilesystem.cpp testFsMock.cpp) if(UNIX) - target_sources(${FSFW_TEST_TGT} PRIVATE - testCommandExecutor.cpp - ) + target_sources(${FSFW_TEST_TGT} PRIVATE testCommandExecutor.cpp) endif() diff --git a/unittests/mocks/cfdp/FaultHandlerMock.h b/unittests/mocks/cfdp/FaultHandlerMock.h index 1c59485ce..5e0945097 100644 --- a/unittests/mocks/cfdp/FaultHandlerMock.h +++ b/unittests/mocks/cfdp/FaultHandlerMock.h @@ -17,7 +17,7 @@ class FaultHandlerMock : public FaultHandlerBase { void noticeOfSuspensionCb(TransactionId& id, ConditionCode code) override; void noticeOfCancellationCb(TransactionId& id, ConditionCode code) override; - void abandonCb(TransactionId& id,ConditionCode code) override; + void abandonCb(TransactionId& id, ConditionCode code) override; void ignoreCb(TransactionId& id, ConditionCode code) override; FaultInfo& getFhInfo(FaultHandlerCode fhCode); From 23d3812fe33e255647b9af9ac9a86a1fb7eee893 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 21 Nov 2022 15:22:25 +0100 Subject: [PATCH 10/10] this is actually important --- src/fsfw_hal/linux/uio/UioMapper.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fsfw_hal/linux/uio/UioMapper.cpp b/src/fsfw_hal/linux/uio/UioMapper.cpp index 9e16ce67e..33e4fd97a 100644 --- a/src/fsfw_hal/linux/uio/UioMapper.cpp +++ b/src/fsfw_hal/linux/uio/UioMapper.cpp @@ -20,7 +20,7 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) { if (S_ISLNK(buf.st_mode)) { char* res = realpath(uioFile.c_str(), nullptr); if (res) { - uioFile = res; + this->uioFile = res; free(res); } else { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -28,7 +28,7 @@ UioMapper::UioMapper(std::string uioFile, int mapNum) : mapNum(mapNum) { #endif } } else { - uioFile = std::move(uioFile); + this->uioFile = std::move(uioFile); } }